A

Admin • 830.13K Points
Coach

Q. What is the output of the below Java program with Enums?

Code:
enum Bus
{
DIESEL, ELECTRIC, HYBRID
int mileage = 10;
}
public class EnumTest2
{
public static void main(String[] args)
{
Bus bus = Bus.ELECTRIC;
System.out.println(bus + ", " + bus.mileage);
}
}
  • (A) 1, 0
  • (B) ELECTRIC, 0
  • (C) ELECTRIC, 10
  • (D) Compiler error
  • Correct Answer - Option(D)
  • Views: 7
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.