Câu 74: GSSP-Java: GIAC Secure Software Programmer-Java
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 wil…
Nội dung câu hỏi
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?
Các lựa chọn
Đáp án được giữ gọn theo nhãn A, B, C, D trong phần bình chọn tương tác.
- A. The code will compile and execute displaying hundred.
- B. The code will not compile because 1000 is not assignment compatible with a byte data type. — đáp án hiện tại
- C. The code will not compile because the argument to the switch cannot be a primitive type byte value.
- D. The code will compile and execute displaying hundred followed by thousand.
Cộng đồng
0 bình luận công khai. Tên thành viên được ẩn một phần.