Which is the Best Java Web Framework ?

Java - Interview Questions and Answers on Exceptions

Q1.  Difference between Checked and Unchecked exceptions ?

Ans. Checked exceptions and the exceptions for which compiler throws an errors if they are not checked whereas unchecked exceptions and caught during run time only and hence can't be checked.

Q2.  How does a try statement determine which catch clause should be used to handle an exception?

Ans. When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.

Q3.  Give an Example of checked and unchecked exception ?

Ans. ClassNotFoundException is checked exception whereas NoClassDefFoundError is a unchecked exception.

Q4.  Name few Java Exceptions ?

Ans. IndexOutofBound , NoClassDefFound , OutOfMemory , IllegalArgument.

Q5.  How can we make sure that a code segment gets executed even in case of uncatched exceptions ?

Ans. By putting it within finally.

Q6.  Explain java.lang.OutOfMemoryError ?

Ans. This Error is thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

Q7.  Is it necessary that each try block to be followed by catch block ? 

Ans. It should be followed by either catch or finally block.

Q8.  Can finally block be used without catch ?

Ans. Yes but should follow "try" block then.

Q9.   What is exception propogation ?

Ans. Passing the exception object to the calling method.

Q10. What is the package name for IOexception class?

Ans.java.io

Q11. Which is the Parent Class of IOexception?

Ans.exception

Q12. Which interfaces are implemented by FileNotFoundException?

Ans.[serializable]

Q13. Which interfaces are implemented by IllegalArgumentException?

Ans.[serializable]

Q14. Which is the Parent Class of FileNotFoundException?

Ans.ioexception

Q15. What is the package name for Exception class?

Ans.java.lang

Q16. Which is the Parent Class of Exception class?

Ans.throwable

Q17. Which interfaces are implemented by Exception?

Ans.[serializable]

Q18. Which interfaces are implemented by IOexception?

Ans.[serializable]

Q19. What is the package name for FilenotFoundException class?

Ans.java.io

Q20. What is the package name for IllegalArgumentException class?

Ans.java.lang

Q21. Which is the Parent Class of IllegalArgumentException?

Ans.runtimeexception

Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus




×

Try our new Java Interview Questions Search Tool.

There are more than 1000 questions with practice tests.

It's updated daily and It's Awesome.


×

Try our new Java Practice Test tool.

There are more than 200 questions and expanding quickly. It's updated daily and It's Awesome.