Return to site

JAVA CERTIFICATION QUESTION: The arrow and colon delimiters in Java switch/case structures

· java,ocp

What’s the difference between these two delimiters—and when can they work together?

Given

 and

 

Which is true? Choose one.

A. The syntax of line n1 is invalid in a switch expression.

B. The syntax of line n2 is invalid in a switch expression.

C. The syntax of line n3 is invalid in a switch expression.

D. The main method fails to compile for a reason not listed.

E. The main method compiles fine and prints up to console.