🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Enums: all 10 questions

Quiz: Java Enums · Question 2 of 10

What is the main advantage of an enum over int constants for a method parameter?

What is the main advantage of an enum over int constants for a method parameter?

  1. A.The compiler only accepts valid constants of that type
  2. B.Enums use less memory than ints
  3. C.Enums can be added together
  4. D.Enums are faster to print
Answer & explanation

Correct answer: The compiler only accepts valid constants of that type

A Status parameter cannot receive 42 or any other invalid value; an int parameter can.

Can you get the rest right without peeking?

Take the timed Quiz: Java Enums quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →