Q. What is the output of the below Java program with SWICH and ENUM?

Code:
static enum ANIMAL {GOAT, TIGER, CAMEL}
public static void main(String args[])
{
  ANIMAL ani = ANIMAL.CAMEL;
  switch(ani)
  {
    case GOAT: System.out.println("GOAT");break;
    case CAMEL: System.out.println("CAMEL");break;
    case TIGER: System.out.println("TIGER");break;
  }

}
  • (A) CAMEL
  • (B) GOAT
  • (C) TIGER
  • (D) Compiler error
πŸ’¬ Discuss
βœ… Correct Answer: (A) CAMEL

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
273
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
96%
Success Rate