Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training
SCJP Online Training » Discussions

DiagnosticExam QS NO-15

try{

}catch(Exception e){

System.out.println(e);

}

What will be the result of attempting to compile and run the above code fragment?

A.Compiles successfully, but the statement System.out.println(e); never be executed, because there is no statement in the try block.

B.Compiles successfully, and the statement System.out.println(e); will be executed, if an exception is thrown above the try block.

C.Does not compile, because the reference variable 'e' cannot be printed.

D.Does not compile, because the exception java.lang.Exception is never thrown in body of corresponding try statement.


I think option B will also be the correct.Because if an exception is thrown in the try block then the println statement in the catch block will be executed.

ExamLab © 2008 - 2018