Java Interview Questions For 2 Years Experienced
Java Interview Questions For 2 Years Experienced
• Static methods are those which belong to the class.They do not belong
to the object and in overriding, object decides which method is to be
called.
Yes, we can overload main method in java but when you run your program,
JVM will search for public static void main(String[] args) and execute that
method.
HashMap vs HashSet:
Parameter HashMap HashSet
Three objects will be created here, two in heap memory and one in String
constant pool.
Unchecked exceptions are those exceptions which are not checked at compile
time. Java won’t complain if you do not handle the exception.
ArrayList
ArrayList vs LinkedList:
Parameter ArrayList LinkedList
sleep
wait
It causes current thread to wait until either another thread invokes the notify()
method or the notifyAll() method for this object
It must be called from synchronized context i.e. from block or method.It means
before wait() method is called,current thread must have lock on that object.
It releases lock on the object on which it is called and added to wait list, so
another thread can acquire lock on the object.