Loading
notes intro/old submit AP Problems the dump links
 

Quiz 17 - arraylist

 

id:

1. Which of the following could not be a type of arraylist?

Accounts Sales Strings Bowlers All of these could work

2.True or false: You need to declare the maximum size of an Arraylist when you initialize it : true false

3. True or false: Arraylists are an objects made up of an array. true false

 

4. Which of the following is the way to declare an Arraylist called allAccounts of class Account:

Arraylist allAccounts = new Arraylist();
Arraylist allAccounts = new Accounts();
Arraylist<Account> allAccounts = new Arraylist();
Arraylist<Account> allAccounts = new Arraylist<Account>();

 

5.To print out all elements of an Arraylist of Strings called names, we could say:

I.
for (int i=0; i<names.size(); i++)
System.out.println(names.get(i));
II.
for (int i=0; i<names.size(); i++)
System.out.println(names);
III.
for (String e:names)
System.out.println(e);

I only II only III only I and III II and III

 

6. To get the size of an arraylist we would say:
name.size
name.size()
name.length
name.length()

 

7. To use an int in an arraylist you need to use a wrapper class. Which of the following is the right way to do to convert int x?
Integer j= <int>x;
Integer j= new Int (x);
Integer j= new Integer (x);
Int j= new Int (x);