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

Home > Java Programming > Exceptions > Questions and Answers

Q:
1. try{
2. // some code here
3.} catch (NullPointerException e1) {
4. System.out.print("a");
5.} catch (Exception e2) {
6. System.out.print("b");
7.} finally {
8. System.out.print("c");
9.}

If some sort of exception is thrown at line 2, which output is possible?
A. a B. b
C. c D. ac
E. abc

Answer and Explanation

Answer:ac

Explanation:
You can have any number of catch blocks, if exception is occurred from try, then it will check in immediate catch , if immediate catch block is able to handle then it will go inside that catch block. If not then it will go and check next available catch block. and finally will execute whether exception occurs or not. So answer is D).

Comment on this Question

Name:

Loading...




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