자격증/OCJP_ExamB

QUESTION 41

IT grow. 2018. 7. 11. 14:19
반응형

QUESTION 41 


Given: 

 

public class Test { 

    public enum Dogs {collie, harrier};

     public static void main(String [] args) {

         Dogs myDog = Dogs.collie;

         switch (myDog) {

         case collie:

             System.out.print("collie ");

         case harrier:

             System.out.print("harrier ");

         }

     }

 } 

 

What is the result? 

 

A. collie 

B. harrier 

C. Compilation fails. 

D. collie harrier 

E. An exception is thrown at runtime. 


Solution : D 



plus imformation

switch 문에 break 가 없기 때문에 실패로 끝날 것이다.


 

반응형