Submitted by c-admin on Wed, 05/29/2019 - 05:40
What sequence of digits will the following program print?
import java.util.* ;
public class ListTest{
public static void main(String args[]){
List s1 = new ArrayList( );
s1.add("a");
s1.add("b");
s1.add(1, "c");
List s2 = new ArrayList( s1.subList(1, 1) );
s1.addAll(s2);
System.out.println(s1);
} }
Select 1 option
A. The sequence a, b, c is printed.
B. The sequence a, b, c, b is printed.
C. The sequence a, c, b, c is printed.
D. The sequence a, c, b is printed.
E. None of the above.
Submitted by c-admin on Wed, 05/29/2019 - 05:37
Which of the following are benefits of ArrayList over an array?
Select 1 option
A. You do not have to worry about the size of the ArrayList while inserting elements.
B. It consumes less memory space.
C. You do not have to worry about thread safety.
D. It allows you to write type safe code.
Submitted by c-admin on Wed, 05/29/2019 - 05:32
Consider the following code to count objects and save the most recent object ...
int i = 0 ;
Object prevObject ;
public void saveObject(List e ){
prevObject = e ;
i++ ;
}
Which of the following calls will work without throwing an exception?
Select 3 options
A. saveObject( new ArrayList() );
B. Collection c = new ArrayList(); saveObject( c );
C. List l = new ArrayList(); saveObject(l);
D. saveObject(null);
E. saveObject(0); //The argument is the number zero and not the letter o
Submitted by c-admin on Wed, 05/29/2019 - 05:28
Identify the correct statements about ArrayList?
Select 3 options
A. Standard JDK provides no subclasses of ArrayList.
B. You cannot store primitives in an ArrayList.
C. It allows constant time access to all its elements.
D. ArrayList cannot resize dynamically if you add more number of elements than its capacity.
E. An ArrayList is backed by an array.
Pages