Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 9 Assume that the following code has been executed (same for Questions 7 thru 10) : ArrayList plot = new ArrayList (); Point p

Question 9

Assume that the following code has been executed (same for Questions 7 thru 10):

ArrayList plot = new ArrayList(); Point p = new Point( 12, 16 ); plot.add( p ); plot.add( new Point( 0, 0 ) ); plot.add( new Point( 4, 8 ) ); plot.add( 2, new Point( 5, 10 ) ); p = plot.get( 0 ); p = plot.remove( 1 ); plot.add( new Point( -5, 5 ) ); 

Which Point is returned by the following expression? plot.get( 2 )

0,0
12,16
4,8
-5,5
None -- the statement throws a runtime exception

Question 10

Assume that the following code has been executed (same for Questions 7 thru 10):

ArrayList plot = new ArrayList(); Point p = new Point( 12, 16 ); plot.add( p ); plot.add( new Point( 0, 0 ) ); plot.add( new Point( 4, 8 ) ); plot.add( 2, new Point( 5, 10 ) ); p = plot.get( 0 ); p = plot.remove( 1 ); plot.add( new Point( -5, 5 ) ); 

Which Point is returned by the following expression? plot.get( 5 )

The value null is returned
5,10
-5,5
4,8
None -- the statement throws a runtime exception

Question 11

Assume that the following code has been executed (same for Questions 11 thru 14):

ArrayList nums = new ArrayList(); nums.add( 12 ); nums.add( 32 ); nums.add( 15 ); nums.add( 2, 11 ); nums.add( 6 ); int s = nums.size() ; int sum = 0; Iterator it = nums.iterator(); while( it.hasNext() ) { int n = it.next(); if ( n % 2 == 1 ) sum = sum + n; } nums.remove( 0 ); 

What is the value of the variable 's'?

6
4
5
2
7

Question 12

Assume that the following code has been executed (same for Questions 11 thru 14):

ArrayList nums = new ArrayList(); nums.add( 12 ); nums.add( 32 ); nums.add( 15 ); nums.add( 2, 11 ); nums.add( 6 ); int s = nums.size(); int sum = 0; Iterator it = nums.iterator(); while( it.hasNext() ) { int n = it.next(); if ( n % 2 == 1 ) sum = sum + n; } nums.remove( 0 ); 

What is the value of the variable 'sum'?

76
78
26
50
15

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago