Java Enums MCQs with answers Page - 1

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 • 825.56K Points
Coach

Q. Which class does all the Enums extend?

  • (A) Object
  • (B) Enums
  • (C) Enum
  • (D) EnumClass

A

Admin • 825.56K Points
Coach

Q. What is the main purpose of using enums in Java?

  • (A) To define a class
  • (B) To create multiple instances of a method
  • (C) To define a set of named constants
  • (D) To handle runtime exceptions

A

Admin • 825.56K Points
Coach

Q. Which keyword is used to declare an enum in Java?

  • (A) enum
  • (B) enumeration
  • (C) enumClass
  • (D) define

A

Admin • 825.56K Points
Coach

Q. Can a Java enum have constructors and methods?

  • (A) No, enums cannot have any methods
  • (B) Yes, but only constructors
  • (C) Yes, enums can have constructors and methods
  • (D) Only static methods are allowed

A

Admin • 825.56K Points
Coach

Q. What is the base class of all Java enums?

  • (A) Object
  • (B) Enum
  • (C) Enumeration
  • (D) EnumBase

A

Admin • 825.56K Points
Coach

Q. What will be the output of the following code?

Code:
enum Day { MONDAY, TUESDAY }
System.out.println(Day.MONDAY.ordinal());
  • (A) 1
  • (B) 0
  • (C) MONDAY
  • (D) Error

A

Admin • 825.56K Points
Coach

Q. Which method returns all constants of an enum type?

  • (A) enumValues()
  • (B) getEnumConstants()
  • (C) values()
  • (D) constants()

A

Admin • 825.56K Points
Coach

Q. Can you use switch-case with enum in Java?

  • (A) No, enums cannot be used in switch
  • (B) Only with numeric enums
  • (C) Yes, Java supports enums in switch-case
  • (D) Only in Java 8 and above

A

Admin • 825.56K Points
Coach

Q. Can enums in Java implement interfaces?

  • (A) No
  • (B) Yes, but only one interface
  • (C) Yes, enums can implement one or more interfaces
  • (D) Only marker interfaces

A

Admin • 825.56K Points
Coach

Q. Which method is used to get an enum constant by name?

  • (A) fromName()
  • (B) nameOf()
  • (C) get()
  • (D) valueOf()
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