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

Home > Java Programming > Exceptions > Questions and Answers

Q: System.out.print("Start ");
try{
System.out.print("Hello world");
throw new FileNotFoundException();
}
System.out.print(" Catch Here "); /* Line 7 */
catch(EOFException e){
System.out.print("End of file exception");
}
catch(FileNotFoundException e){
System.out.print("File not found");
}
and given that EOFException and FileNotFoundException are both subclasses ofIOException, and further assuming this block of code is placed into a class, which statement is most true concerning this code?
A. The code will not compile B. Code output: Start Hello world File Not Found.
C. Code output: Start Hello world End of file exception. D. Code output: Start Hello world Catch Here File not found.

Answer and Explanation

Answer:The code will not compile

Explanation:
Line 7 will cause a compiler error. The only legal statements after try blocks are either catch or finally statements.
Option B, C, and D are incorrect based on the program logic described above. If line 7 was removed, the code would compile and the correct answer would be Option B.

Comment on this Question

Name:

Loading...




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