Preskoči na glavni sadržaj
Prijava
Sign up for FREE
arrow_back
Biblioteka

Arraylists Quiz

star
star
star
star
star
Posljednje ažuriranje about 2 years ago
22 questions
1
1
Pitanje 1
1.

What is output by the code below? ArrayList<String> list = new ArrayList<String>(); list.add("three"); list.remove(0); list.add("one"); System.out.println(list);

1
1
Pitanje 3
3.

What is output by the code below? List<String> list = new ArrayList<String>(); list.add("one"); list.add(0,"two"); list.set(0,"three"); list.add(1,"four"); list.remove(0); list.set(1,"five"); System.out.println(list);

1
Pitanje 5
5.

Quiz: Which of the following would fill blank <*1> to add a new It to itListOne?

1
Pitanje 6
6.

What is the output by the code below? java public class It { private int stuff; private String word; public It(int x, String w){ stuff = x; word = w; } public int getStuff(){ return stuff; } public String toString(){ return "" + stuff + " " + word ; } } //code in client class ArrayList<It> x; x = new ArrayList<It>(); x.add(new It(5, "dog")); x.add(new It(3, "cat")); System.out.println(x.get(0).getStuff());

1
Pitanje 7
7.

Consider the following Dog class. Which of the following answer choices would create a List of Dog references?

1
Pitanje 8
8.

Given the Dog and DogPound classes, which code could fill line 1 so that method printDogs would print all Dogs in the DogPound?

1
Pitanje 9
9.

// client code found in PigRunner.java

ArrayList< Pig > list;

list = new ArrayList< Pig >();

< *1 >

Which of the following could fill < *1 > to add a Pig to the list?

I. list.add( 5 );

II. list.add( 5, "piggy" );

III. list.add( new Pig( 5, "piggy" ) ) ;

1
Pitanje 10
10.

Consider the following Pig class and client code below. class Pig { public Pig( int x, String y ) { //code not shown } } // client code found in PigRunner.java ArrayList< Pig > list; list = new ArrayList< Pig >(); // several Pigs have been added to the list < *1 > Which of the following could fill < *1 > to print out each Pig in the list on a separate line? I. for( Pig it : list ) System.out.println( it ); II. for( Pig it : list ) System.out.println( list.get( it ) ); III. for( Pig it : list ) System.out.println( it );

1
Pitanje 11
11.
1
Pitanje 12
12.
1
1
1
1
1
1
Pitanje 18
18.
1
Pitanje 19
19.
1
Pitanje 20
20.
1
Pitanje 21
21.
1
Pitanje 22
22.
Pitanje 2
2.

What is output by the code below? ArrayList<String> list = new ArrayList<String>(); list.add("one"); list.set(0, "two"); list.add(0, "three"); System.out.println(list);

Pitanje 4
4.

What is output by the code below? List<String> bigList = new ArrayList<String>(); bigList.add(0,"one"); bigList.add("two"); bigList.add(0,"three"); bigList.add("four"); bigList.remove(0); bigList.add(0,"five"); bigList.set(2,"six"); bigList.set(3,"seven"); bigList.add("zero"); System.out.println(bigList.indexOf("six"));

Pitanje 13
13.
Pitanje 14
14.
Pitanje 15
15.
Pitanje 16
16.
Pitanje 17
17.