Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Instructions: For each question, choose the single best answer. Make your choice by
clicking on its button. You can change your answers at any time. When the quiz is
graded, the correct answers will appear in the box after each question.
B.
C.
D.
After the code has exectued, what is the capactiy of list? What is its size?
A.
3, 3
B.
3, 10
C.
10, 3
D.
10, 10
"Andy" );
"Bart" );
"Carl" );
0, "Eve" );
Eve
B.
Andy
C.
Bart
D.
carl
"Andy"
"Bart"
"Carl"
"Doug"
"Elmo"
);
);
);
);
);
Which of the following will replace the element "Carl" with "Zoltan" ?
A.
list[2] = "Zoltan" ;
B.
C.
D.
"Andy"
"Bart"
"Carl"
"Doug"
"Elmo"
);
);
);
);
);
Which of the following will change the list so that it looks like:
Andy
Bart
Carl
Doug
Oscar
Elmo
A.
list.add( 3, "Oscar" ) ;
B.
list.add( 4, "Oscar" ) ;
C.
list.set( 3, "Oscar" ) ;
D.
list.set( 4, "Oscar" ) ;
"Andy"
"Bart"
"Carl"
"Doug"
"Elmo"
);
);
);
);
);
Which of the following will change the list so that it looks like:
Andy
Bart
Doug
Elmo
A.
list.remove( 3 );
B.
list.remove( 2 );
C.
list.add( 2, null );
D.
"Andy"
"Bart"
"Carl"
"Doug"
"Elmo"
);
);
);
);
);
Which of the following will change the list so that it looks like:
Andy
Bart
Carl
Doug
A.
list.remove( list.size() );
B.
list.remove( list.size()-1 );
C.
list.remove( 5 );
D.
list.clear( "Elmo" );
"Andy"
"Bart"
"Carl"
"Doug"
"Elmo"
);
);
);
);
);
while( iter.___________ )
System.out.println( iter.___________ );
iterator()
hasNext()
next()
B.
iterator()
next()
nextElement()
C.
elements()
empty()
next()
D.
iterator()
more()
get()
"Andy"
"Bart"
"Carl"
"Doug"
"Elmo"
);
);
);
);
);
String
list
B.
String
iterator()
C.
int
String
D.
iterator()
String
name
next()
name
list
10. which of the following declarations would be appropriate for a list that is expected
to contain integers?
A.
B.
C.
D.
11. What equals() method must you override when defining a class of objects you
expect to hold in a ArrayList ?
A.
B.
C.
D.