CARVIEW |
Java ArrayList CIP
Question 1
List is inherited from which interface in Java?
Formattable
Serializable
Collection
None of these
Question 2
Which class/classes among the given are among the main classes which implements the list interface?
ArrayList
Vector
Linked List
None of these
Question 3
What is special about the list's iterator compared to the collection's iterator.
It can be constructed easily
It can access all the data in the list
It can traverse backward in the list.
None of these
Question 4
What is the syntax to create an array list of integers -
Arraylist<Integer> al = new Arraylist<Integer>();
Arraylist<Integer> al = new list[] ();
Arraylist<Integer> al = new List<Integer>();
None of these
Question 5
Advantage of ArrayList over normal array is/are,
Rich Library Functions
Dynamic size
Can access all the data at constant time
All of the above
Question 6
How does ArrayList handle data when it is full?
Creates a new array of double size and copies old data to this array.
Adds space in the pre existing array.
Cannot allocate memory more than the memory allocated to it.
None of the above
Question 7
Average time to insert n+1 items in an ArrayList,
θ( n + 1 )
θ( 1 )
θ( n )
θ( nlogn )
Question 8
Among the given options which is/are the methods of ArrayList in Java?
Remove
Add
Contains
LastIndexOF
All of the above
Question 9
What is the output of the code,
import java.util.*;
class HelloWorld {
public static void main(String[] args) {
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(10);
al.add(20);
al.add(30);
al.add(40);
al.add(50);
System.out.println(al.isEmpty());
al.clear();
System.out.println(al.isEmpty());
}
}
false
false
false
true
Error
None of the above
Question 10
What is the time complexity of remove() method of arrayList?
O(1)
O(n)
O( log n )
None of the above
There are 10 questions to complete.