자격증/OCJP_ExamB

QUESTION 43

IT grow. 2018. 7. 13. 18:09
반응형

QUESTION 43 


Given: 

 


static void test() throws Error { 
     if (true) throw new AssertionError(); 
    System.out.print("test "); 
 } 
 public static void main(String[] args) { 
     try { test(); } 
    catch (Exception ex) { System.out.print("exception "); } 
     System.out.print("end "); 
 } 
}


What is the result? 

 

A. end 

B. Compilation fails. 

C. exception end 

D. exception test end 

E. A Throwable is thrown by main. 

F. An Exception is thrown by main.


Solution : E 




plus imformation 


Exception in thread "main" java.lang.AssertionError

     at A.test(Main.java:2)

     at A.main(Main.java:6)


반응형