A

Admin • 828.03K Points
Coach

Q. What is the output of the following code?

Code:
enum Color { RED, GREEN, BLUE }
System.out.println(Color.RED.name());
  • (A) 0
  • (B) RED
  • (C) Color.RED
  • (D) Red
  • Correct Answer - Option(B)
  • Views: 10
  • Filed under category Java
  • Hashtags: Java Enums

Explanation by: Admin
The `name()` method returns the exact string name of the constant, so it prints `RED`.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.