Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


What is not possible to do with a Java class declared as final?

  1. Instantiate it

  2. Declare methods within it

  3. Inherit from it

  4. Create a static method in it

The correct answer is: Declare methods within it

A Java class declared as final means that it cannot be extended or subclassed by any other class. This ensures that the class cannot be inherited from or overridden. Hence, it is not possible to declare methods within a final class as it goes against the purpose of having a final class, which is to prevent any modifications or inheritance. A is incorrect because a final class can still be instantiated. C is incorrect because a final class cannot be inherited from. D is incorrect because a static method can still be created within a final class, as long as it is not overridden.