Java Enums MCQs with answers Page - 2

You will find multiple-choice questions (MCQs) related to #Java Enums here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

A

Admin • 828.43K Points
Coach

Q. What will happen if you try to instantiate an enum using `new` keyword?

  • (A) It creates a new enum instance
  • (B) It results in a compile-time error
  • (C) It throws a runtime exception
  • (D) It works only inside the enum class

A

Admin • 828.43K Points
Coach

Q. Which of the following is TRUE about enum constructors?

  • (A) Enum constructors must be public
  • (B) Enum constructors must be private or package-private
  • (C) Enum constructors can be protected
  • (D) Enum constructors must be static

A

Admin • 828.43K Points
Coach

Q. What does the `name()` method of an enum return?

  • (A) The ordinal position
  • (B) The enum class name
  • (C) The name of the constant as a string
  • (D) The default value of the enum

A

Admin • 828.43K Points
Coach

Q. Which of these methods are available for enums by default?

  • (A) toString(), valueOf(), name(), ordinal()
  • (B) equals(), hashCode(), add()
  • (C) clone(), finalize(), compareTo()
  • (D) parse(), format(), get()

A

Admin • 828.43K Points
Coach

Q. Which of the following is not allowed in a Java enum?

  • (A) Implementing an interface
  • (B) Defining methods
  • (C) Extending another class
  • (D) Having instance variables

A

Admin • 828.43K 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

A

Admin • 828.43K Points
Coach

Q. Which interface do all enums implicitly implement in Java?

  • (A) Serializable
  • (B) Cloneable
  • (C) Comparable
  • (D) Iterable

A

Admin • 828.43K Points
Coach

Q. How many instances are created for each enum constant?

  • (A) Multiple per usage
  • (B) None
  • (C) Only one (singleton-like)
  • (D) Depends on how it’s called

A

Admin • 828.43K Points
Coach

Q. Which method compares the ordinal values of two enum constants?

  • (A) equals()
  • (B) name()
  • (C) compareTo()
  • (D) ordinal()

A

Admin • 828.43K Points
Coach

Q. What is the result of calling `toString()` on an enum constant?

  • (A) Its ordinal number
  • (B) Its name in lowercase
  • (C) Its name as declared
  • (D) It returns null
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More