Welcome Guest | Sign in | Register
Threads - Discussion Page For Q.2960 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Threads > Questions and Answers

Q: Predict the output?

5. try{
6. throw new Exception();
7. }catch(Error e){
8. System.out.print("EXCE");
9. }
A. Compilation error: Error cannot catch B. Run time exception 
C. Output: EXCE D. None of the above

Answer and Explanation

Answer:Run time exception 

Explanation:
No problem for putting Error in catch but it will not catch Exception vice versa,

Following catch block will catch both Exception and Error

5. try{
6. throw new Exception();
7. }catch(Throwable e){
8. System.out.print("EXCE");
9. }

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.