1. 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.
  2. What modifiers can be used with a local inner class? - A local inner class may be final or abstract.
  3. What is the purpose of the File class? - The File class is used to create objects that provide access to the files and directories of a local file system.
  4. Can an exception be rethrown? - Yes, an exception can be rethrown.
  5. When does the compiler supply a default constructor for a class? - The compiler supplies a default constructor for a class if no other constructors are provided.
  6. If a method is declared as protected, where may the method be accessed? - A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

See Java Interview Questions and Answers : Part 3 for more Java/J2EE Interview Questions.




Sandeep Joshi
Mathematics, Technology and Programming are my passion. I am a part of Java Ecosystem and through this blog, I contribute to it. I am here to blog about my interests, views and experiences.
I am on Google+ and Facebook.
I feel proud to be listed as a "National Memory Record Holder" in the Limca Book of Records, 2009 and have attempted for an International Memory record in the Guiness Book of Records. I can remember the value of PI upto 10,000 digits after the decimal (3.1415.....). You can contact me on javagenious.com(At)gmal.com ; I would like to hear from you :)