Home / Programming MCQs / JAVA MCQs / Question

R

Ram Sharma • 178.09K 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

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.