Java Basics - Interview Questions and Answers

  1. When a thread is created and started, what is its initial state?
    A thread is in the ready state after it has been created and started.
  2. What is the purpose of finalization?
    The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.
  3. What is the Locale class?
    The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.
  4. What is the difference between a while statement and a do statement?

    A while statement checks at the beginning of a loop to see whether the next loop iteration should occur.

    A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.

  5. What is the difference between static and non-static variables?
    A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.
  6. How are this() and super() used with constructors?
    this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

« Prev   [ Page 11 of 17  Jump... Next »

Jump to page : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |