Skip to main content

Posts

Showing posts from July, 2011

Java Exceptions Interview Questions - Latest

Explain the user defined Exceptions? User defined Exceptions are custom Exception classes defined by the user for specific purpose. A user defined exception can be created by simply sub-classing an Exception class or a subclass of an Exception class. This allows custom exceptions to be generated (using throw clause) and caught in the same way as normal exceptions. Example: class CustomException extends Exception { } What classes of exceptions may be caught by a catch clause? A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types. Errors are generally irrecoverable conditions What is the difference between exception and error? Error's are irrecoverable exceptions. Usually a program terminates when an error is encountered. What is the difference between throw and throws keywords? The throw keyword denotes a statement that causes an exception to be initiated. It takes the Exception object to be thrown as an a