MCQs
A abstract class is incomplete by itself and relies upon its subclasses to provide complete
implementation. If we declare a class final then no class can inherit that class, an abstract
class needs its subclasses hence both final and abstract cannot be used for a same class.
Hash table based implementation of the Map interface.
Collection interface is inherited by all other interfaces like Set, Array, Map etc. It
defines core methods that all the collections like set, map, arrays etc will have
unmodifiableCollection() is available for al collections, Set, Map, List etc.
None.
clear() method removes all the elements from invoking collection.
Java handles deallocation of memory automatically, we do not need to explicitly delete an element.
Garbage collection only occurs during execution of the program. When no references to the object
exist, that object is assumed to be no longer needed, and the memory occupied by the object can
be reclaimed.
Declaring a class final implicitly declares all of its methods final, and makes the class inheritable.
Operator new dynamically allocates memory for an object and returns a reference to it.
This reference is address in memory of the object allocated by new.
Option D is correct. By a process of elimination.
Option A is wrong. The variable d is a member of the Test class and is never directly set to null.
Option B is wrong. A copy of the variable d is set to null and not the actual variable d.
Option C is wrong. The variable d exists outside the start() method (it is a class member). So, when the start() method finishes the variable d still holds a reference.