NEW
Font size
WorksheetsArrayList Class
Total questions: 15
Worksheet time: 18mins
Which of the following is not a property of an ArrayList Class?
Elements can be added or removed from the Array List collection at a specific point in time
The ArrayList is not guaranteed to be sorted
The capacity of an ArrayList is the number of elements the ArrayList can hold
It also allows duplicate elements
Which of the following does not belong to the group?
ArrayList(Int)
ArrayList()
ArrayList(ICollection)
ArrayList(Int32)
Which of the following properties gets the number of elements actually contained in the ArrayList?
Count
Capacity
Size
Item[Int32]
Which of the following properties gets or sets the number of elements that the ArrayList can contain?
Count
Capacity
Size
Item[Int32]
Which of the following is not a property of ArrayList Class?
Count
Capacity
Size
IsFixedSize
Which of the following is not a method of an ArrayList Class?
Close()
Clear()
Clone()
GetType()
Which of the following methods creates a shallow copy of the ArrayList?
CopyTo(Array)
CopyTo(Array, Int32)
Clone()
GetType()
Which of the following methods Inserts an element into the ArrayList at the specified index?
Insert(Int32, Object)
InsertRange(Int32, ICollection)
CopyTo(Array)
CopyTo(Array, Int32)
Which of the following methods removes all elements from the ArrayList?
Clear()
Remove(Object)
Delete()
Erase(Object)
Which of the following methods removes the element at the specified index of the ArrayList?
RemoveAt(Int32)
Remove(Object)
RemoveRange(Int32, Int32)
Clear()
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?
3, 3
3, 10
10, 3
10, 10
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?
Eve
Andy
Bart
Carl
Declare and construct an ArrayList with an initial capacity of 20 references to Object.
Object list(20) = new ArrayList() ;
ArrayList list[20] = new ArrayList() ;
ArrayList[Object] list = new ArrayList(20) ;
ArrayList<Object> list = new ArrayList<Object>(20) ;
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
list.add( 3, "Oscar" ) ;
list.add( 4, "Oscar" ) ;
list.set( 3, "Oscar" ) ;
list.set( 4, "Oscar" ) ;
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
list.remove( list.size() );
list.remove( list.size()-1 );
list.remove( 5 );
list.clear( "Elmo" );
