Search your topic in Java2share
Home > FAQs
eXTReMe Tracker

Exception Handling FAQs

Untitled Document

Q29. Is it possible to use throws keyword for any java class?
Ans.  No, we can use throws keyword only for Throwable classes. Otherwise we will get compile time error saying Incompatible types.
Q30. If we are taking catch block for an exception but there is no chance of rising that exception in try then what will happen?
Ans.  If there is no chance of raising an exception in try then we are not allow to write catch block for that exception violation leads to compile time error. But this rule is applicable only for fully checked exception.
Q31.  Explain Exception Handling keyword?
Ans.  Exception Handling keyword:
Try :- To maintain Risky code.
                Catch:- To maintain Exception Handling code.
                Finally:- To maintain the clean up code.
                Throw:- To handover our created exception object to the JVM explicitly.
                Throws:- To delegate the responsibilities of Exception Handling to the caller.

Q32. Which class act as root for entire java Exception hierarchy?
Ans.   Throwable class act as root for entire java Exception hierarchy.