wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

ArrayList Class

Total questions: 15

Worksheet time: 18mins

Name
Class
Date
1.

Which of the following is not a property of an ArrayList Class?

a)

Elements can be added or removed from the Array List collection at a specific point in time

b)

The ArrayList is not guaranteed to be sorted

c)

The capacity of an ArrayList is the number of elements the ArrayList can hold

d)

It also allows duplicate elements

2.

Which of the following does not belong to the group?

a)

ArrayList(Int)

b)

ArrayList()

c)

ArrayList(ICollection)

d)

ArrayList(Int32)

3.

Which of the following properties gets the number of elements actually contained in the ArrayList?

a)

Count

b)

Capacity

c)

Size

d)

Item[Int32]

4.

Which of the following properties gets or sets the number of elements that the ArrayList can contain?

a)

Count

b)

Capacity

c)

Size

d)

Item[Int32]

5.

Which of the following is not a property of ArrayList Class?

a)

Count

b)

Capacity

c)

Size

d)

IsFixedSize

6.

Which of the following is not a method of an ArrayList Class?

a)

Close()

b)

Clear()

c)

Clone()

d)

GetType()

7.

Which of the following methods creates a shallow copy of the ArrayList?

a)

CopyTo(Array)

b)

CopyTo(Array, Int32)

c)

Clone()

d)

GetType()

8.

Which of the following methods Inserts an element into the ArrayList at the specified index?

a)

Insert(Int32, Object)

b)

InsertRange(Int32, ICollection)

c)

CopyTo(Array)

d)

CopyTo(Array, Int32)

9.

Which of the following methods removes all elements from the ArrayList?

a)

Clear()

b)

Remove(Object)

c)

Delete()

d)

Erase(Object)

10.

Which of the following methods removes the element at the specified index of the ArrayList?

a)

RemoveAt(Int32)

b)

Remove(Object)

c)

RemoveRange(Int32, Int32)

d)

Clear()

11.

Examine the following code:

ArrayList list = new ArrayList(10) ;

list.add( "Ann" );

list.add( "Bob" );

list.add( "Eve" );


After the code has executed, what is the capacity of list? What is its size?

a)

3, 3

b)

3, 10

c)

10, 3

d)

10, 10

12.

Examine the following code:

ArrayList list = new ArrayList (10) ;


list.add( "Andy" );

list.add( "Bart" );

list.add( "Carl" );

list.add( 0, "Eve" );

What element will be at index 2 of the list?

a)

Eve

b)

Andy

c)

Bart

d)

Carl

13.

Declare and construct an ArrayList with an initial capacity of 20 references to Object.

a)

Object list(20) = new ArrayList() ;

b)

ArrayList list[20] = new ArrayList() ;

c)

ArrayList[Object] list = new ArrayList(20) ;

d)

ArrayList<Object> list = new ArrayList<Object>(20) ;

14.

Examine the following code:

ArrayList list = new ArrayList() ;


list.add( "Andy" );

list.add( "Bart" );

list.add( "Carl" );

list.add( "Doug" );

list.add( "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" ) ;

15.

Examine the following code:

ArrayList list = new ArrayList() ;


list.add( "Andy" );

list.add( "Bart" );

list.add( "Carl" );

list.add( "Doug" );

list.add( "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" );