Question: Question 6 If this method call: myList.size() returns the value 7, what is the range of legal values allowed for the variable x in the

Question 6

If this method call: myList.size() returns the value 7, what is the range of legal values allowed for the variable x in the following method call? myList.get( x )

1 thru 7
0 thru 6
0 thru 7
x may be any int value

Question 7

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 ) );

What value is returned by the following expression? plot.size()

0
3
5
4
2

Question 8

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( 1 )

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

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 )

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

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 )

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!