Oracle
1Z0-803 · Question #141
Given the code fragment: public static void main(Stirng[] args) { int x = 353; int j = x++; switch (j) { case 317: case 353: case 367: System.out.println("Is a prime number."); case 353: case 363: Sys
The correct answer is A. Compilation fails. Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Using Operators and Decision Constructs
Question
Given the code fragment:
public static void main(Stirng[] args) { int x = 353; int j = x++; switch (j) { case 317:
case 353:
case 367:
System.out.println("Is a prime number."); case 353:
case 363:
System.out.println("Is a palindrome."); break; default:
System.out.println("Invalid value."); } } What is the result?
Options
- ACompilation fails
- BIs a prime number.
- CIs a palindrome.
- DIs a prime number.
- EInvalid value.
How the community answered
(24 responses)- A92% (22)
- B4% (1)
- C4% (1)
Explanation
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Topics
#switch statement#duplicate case label#compilation error
Community Discussion
No community discussion yet for this question.