Sail E0 Webinar

MCQs

Total Questions : 97 | Page 10 of 10 pages
Question 91.
void start() {
A a = new A();
B b = new B();
a.s(b);
b = null; /* Line 5 */
a = null; /* Line 6 */
System.out.println("start completed"); /* Line 7 */
}


When is the B object, created in line 3, eligible for garbage collection?


  1.    after line 5
  2.    after line 6
  3.    after line 7
  4.    There is no way to be absolutely certain.
 Discuss Question
Answer: Option D. -> There is no way to be absolutely certain.

No answer description available for this question.


Question 92.

Which of these class is superclass of every class in Java?


  1.    String class
  2.    Object class
  3.    Abstract class
  4.    ArrayList class
 Discuss Question
Answer: Option B. -> Object class

Object class is superclass of every class in Java.


Question 93.

Suppose that you would like to create an instance of a new Map that has an iteration ORDER that 

is the same as the iteration order of an existing instance of a Map. Which concrete implementation 

of the Map interface should be used for the new instance?


  1.    TreeMap
  2.    HashMap
  3.    LinkedHashMap
  4.    The answer depends on the implementation of the existing instance.
 Discuss Question
Answer: Option C. -> LinkedHashMap

The iteration order of a Collection is the order in which an iterator moves through the elements

of the Collection. The iteration order of a LinkedHashMap is determined by the order in which 

elements are inserted.

When a new LinkedHashMap is created by passing a reference to an existing Collection to the

 constructor of a LinkedHashMap the Collection.addAll method will ultimately be invoked.

The addAll method uses an iterator to the existing Collection to iterate through the elements of 

the existing Collection and add each to the instance of the new LinkedHashMap.

Since the iteration order of the LinkedHashMap is determined by the order of insertion, the iteration

 order of the new LinkedHashMap must be the same as the interation order of the old Collection.


Question 94.

What is the return type of Constructors?


  1.    int
  2.    float
  3.    void
  4.    None of the mentioned
 Discuss Question
Answer: Option D. -> None of the mentioned

Constructors does not have any return type, not even void.


Question 95.

What is the stored in the object obj in following lines of code?
box obj;


  1.    Memory address of allocated memory of object.
  2.    NULL
  3.    Any arbitrary pointer
  4.    Garbage
 Discuss Question
Answer: Option B. -> NULL

Memory is allocated to an object using new operator. box obj; just declares a reference to 

object, no memory is allocated to it hence it points to NULL.


Question 96.

Which of these is an incorrect form of using method max() to obtain maximum 

element?


  1.    max(Collection c)
  2.    max(Collection c, Comparator comp)
  3.    max(Comparator comp)
  4.    max(List c)
 Discuss Question
Answer: Option C. -> max(Comparator comp)

Its illegal to call max() only with comparator, we need to give the collection to be 

Question 97.

Which of these packages contain all the collection classes?


  1.    java.lang
  2.    java.util
  3.    java.net
  4.    java.net
 Discuss Question
Answer: Option B. -> java.util

None.


Latest Videos

Latest Test Papers