GIAC
GSSP-JAVA · Question #8
GSSP-JAVA Question #8: Real Exam Question with Answer & Explanation
Sign in or unlock GSSP-JAVA to reveal the answer and full explanation for question #8. The question stem and answer options stay visible for context.
Question
Martin works as a Programmer in Data Net Inc. He writes the following code. 1. class Ques0191{ 2. public static void main(String[] argv){ 3. byte a = 1; 4. switch(a+1){ 5. case 1. 6. System.out.println("One"); 7. case 2. 8. System.out.println("2"); 9. case 2. 10. System.out.println("Two"); break; 11. } 12. } 13. } What will happen when Martin attempts to compile and execute the code?
Options
- AThe code will compile successfully, but a runtime error will occur because of the duplicate
- BThe code will not compile because of the duplicate case label at line number 9.
- CThe code will compile successfully and will execute displaying 2 followed by Two.
- DThe code will not compile because an argument to the switch must be a constant.
Unlock GSSP-JAVA to see the answer
You've previewed enough free GSSP-JAVA questions. Unlock GSSP-JAVA for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.