Friday, October 1, 2010

Java Interview Questions

Top Java Interview Questions
Question: Does Java provide any construct to find out the size of an object?
Question: Give a simplest way to find out the time a method takes for execution without using any profiling tool?
Question: What are wrapper classes?
Question: Why do we need wrapper classes?
Question: What are checked exceptions?
Question: What are runtime exceptions?
Question: What is the difference between error and an exception??
Question: How to create custom exceptions?
Question: If I want an object of my class to be thrown as an exception object, what should I do?
Question: If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object?
Question: How does an exception permeate through the code?
Question: What are the different ways to handle exceptions?
Question: What is the basic difference between the 2 approaches to exception handling...1> try catch block and 2> specifying the candidate exceptions in the throws clause?
When should you use which approach?
Question: Is it necessary that each try block must be followed by a catch block?
Question: If I write return at the end of the try block, will the finally block still execute?
Question: If I write System.exit (0); at the end of the try block, will the finally block still execute