ArrayList<Integer> myList = new
ArrayList<Integer>();
What will happen if you then call
myList.get(0)
a.The call will return the value 0
b.The call will return the value null
c. The call will return the value -1 to indicate that the
index is out of bounds
d.Choice 4 of 4:The call will throw
an IndexOutOfBoundsException
2. The ArrayList class in Java has the following
declaration:
Which of the following statements is true? Select all that
apply.
a.List<Integer> ref = new
ArrayList<Integer>(); has a compiler error
because List can't point to
an ArrayList object
b. List<Object> ref = new
ArrayList<Integer>(); has a compiler error
as List<Object> is not same
as ArrayList<Integer>
c. If we have an ArrayList<Object>, we can put
a String object into location 0 and an Integer object to
location 1. It is because any class in Java is
an Object (extends from Object) by default.
d. ArrayList is a List, so it has all the methods
specified in List
3.
Consider the following generic class declaration:
Which of the following would NOT be allowed in
this class's non-static methods? Select all that apply.
a.Creating a variable of type E (i.e. E
myVar;)
b. Creating an object of type E (i.e. new
E();)
c.Creating an array with elements of
type E (i.e. new E[100]

d.Creating an ArrayList to store elements of
type E (i.e. new ArrayList<E>());
4.An arraylist myAL looks like this
{4,2,1,9,null,null}
What is the size and capacity of myAL?
a.Size=4, Capacity=6
b.Size=6, Capacity=4
c.Neither of the above