Interview Questions for Java III



  1. Can an anonymous class be declared as implementing an interface and extending a class? An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.
  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. For example, closing a opened file, closing a opened database Connection.
  3. What invokes a thread’s run() method? After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread’s run() method when the thread is initially executed.
  4. What is the GregorianCalendar class? The GregorianCalendar provides support for traditional Western calendars.
  5. What is the SimpleTimeZone class? The SimpleTimeZone class provides support for a Gregorian calendar.
  6. What is the Properties class? The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used.
  7. What is the purpose of the Runtime class? The purpose of the Runtime class is to provide access to the Java runtime system.
  8. What is the purpose of the System class? The purpose of the System class is to provide access to system resources.
  9. What is the purpose of the finally clause of a try-catch-finally statement? The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught. For example,

    try
    {
    //some statements
    }
    catch
    {
    // statements when exception is cought
    }
    finally
    {
    //statements executed whether exception occurs or not
    }

  10. 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.
  11. What must a class do to implement an interface? It must provide all of the methods in the interface and identify the interface in its implements clause.


Leave a comment

Name: (Required)

eMail: (Required)

Website:

Comment: