Return to site

☕🎓JAVA CERTIFICATION QUESTION: Enum and inheritance

· java,ocp

Given the code below:

Which of the following suggestions is correct? choose the best answer.

* You must override getPower on line 5

* You must override getPower on lines 2, 3, and 4 (for each constant)

* You must make getPower not abstract

* The code fails to compile on line 1

#java #certificationquestion #ocp

 

https://www.udemy.com/course/ocp-oracle-certified-professional-java-developer-prep/?referralCode=54114F9AD41F127CB99A

All enums implicitly extend java.lang.Enum.

Because a class can only extend one parent, the Java language does not support multiple inheritance of state.

And therefore an enum cannot extend anything else.

So the correct answer is "The code fails to compile on line 1".