GIAC
GSSP-JAVA · Question #95
Peter works as a Programmer in Magi Net Inc. He writes the following code. 1. class Ques0190{ 2. public static void main(String[] argv){ 3. byte a = 100; 4. switch(a){ 5. case 10. 6…
Sign in or unlock GSSP-JAVA to reveal the answer and full explanation for question #95. The question stem and answer options stay visible for context.
Question
Peter works as a Programmer in Magi Net Inc. He writes the following code. 1. class Ques0190{ 2. public static void main(String[] argv){ 3. byte a = 100; 4. switch(a){ 5. case 10. 6. System.out.println("ten"); 7. case 100. 8. System.out.println("hundred"); 9. case 1000. 10. System.out.println("thousand"); 11. } 12. } 13. } What will happen when Peter attempts to compile and execute the code?
Options
- AThe code will compile and execute displaying hundred.
- BThe code will not compile because 1000 is not assignment compatible with a byte data
- CThe code will not compile because the argument to the switch cannot be a primitive type
- DThe code will compile and execute displaying hundred followed by thousand.
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.