Oracle Certified Professional Java Se 8 Programmer · Free Practice Question Easy

Question 45

Consider the code of Test.java file:

What will be the result of compiling and executing Test class?

  • A N
  • B NORTH
  • C Exception is thrown at runtime
  • D Compilation error
Reveal correct answer

Correct answer: D

Explanation

As enum Directions contains more code after constant declarations, hence last constant declaration must be followed by a semicolon.


Correct constant declaration is: 

NORTH("N"), SOUTH("S"), EAST("E"), WEST("W");

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need