41.
What are the basic differences between Hashtable and HashMap?
Hashtable is a legacy class and present from JDK 1, HashMap was added later.
Hashtable is a legacy class and present from JDK 1, HashMap was added later.
Hashtable is synchronized and slower but
HashMap is not synchronized and faster.
Hashtable doesn't allow null keys but HashMap
allows one null key.
42.
What is the basic difference between Comparator and Comparable in Java?
The Comparable interface is used to
define the natural order of object whereas Comparator is used to define custom
order. Comparable can be always one, but we can have multiple comparators to
define customized order for objects.
43.Does
Java have pointers?
No. Not even implicit one’s. Java has
references.
Difference
between reference in Java and pointer in C++:
i)References store an address. That
address is the address in memory of the
object. If you were to look at that address in memory you would see the details
of the object. Pointers in C++, however,
point directly to the object.
ii)You can not perform arithmetic
operations on references. So, adding 1 to a reference and moving to the next
reference is not possible in java, but is possible for pointers in C++.
44.
Does Java have an XOR operator? If so, what is the representation for XOR in
Java?
Yes, Java does have an XOR (Exclusive
Or) operator – it is represented by the caret character – the “^”.
45.
If there is an exception in finalize method, will the object be garbage
collected?
Yes,exception in finalize class doesn't prevent GC.
No comments:
Post a Comment