Java Exception Handling Interview Questions
Q:-1. What is Exception in Java?
Exception means that abnormal condition, An exception is abnormal condition that disturb the normal flow of the program. Whenever exception occurs the program gets terminated now and rest of code will not execute.
Q:-2. What is difference between Checked and Unchecked Exception in Java?
In case of checked exception compiler force to the program to keep try catch block while in case of unchecked exception compiler does not.
Q:-3 .Tell me some check and exceptions?
Q:-4 .Tell me some unchecked and exceptions?
Q:-5.Which class is the parent class Java Exception Hierarchy?
Throwable class is the top class of Exception hierarchy.
Q:-6. Five Exception handling keyword?
Exception Handling Keywords
Q:-7.Why try block is used?
Try block is used to keep all the code where exception can come.
Q:-8. Why catch block is used?
Catch block is used to keep all the Exception handling code.
Q:-9. Can we keep try with finally?
Yes we can keep try with finally but in this case exception is not handled because there is no catch block.
Q:-10. Can we keep only try block?
No, we cannot keep only try block.
Q:-11. Is it necessary to put try-catch block in case of unchecked exception?
NO, it’s mandatory to put the try-catch block in case of unchecked exception.
Q:-12.Is it necessary to put try-catch block in case of checked exception?
Yes, it’s mandatory to put the try-catch block in case of checked exception.