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 can be said about a final class in Java?

  1. It cannot be instantiated

  2. It cannot have methods

  3. It cannot be inherited

  4. It can only have static methods

The correct answer is: It cannot have methods

A final class in Java is a class that cannot be inherited and cannot have its internal states modified by any external classes. This means that Option A is incorrect as a final class can still be instantiated, but it cannot be used as a base class for any other classes to inherit from. Option C is also incorrect as a final class cannot be inherited by any other classes. Option D is incorrect because a final class can still have non-static methods, but those methods cannot be overridden by any subclass. Therefore, the only correct statement about a final class in Java is that it cannot have methods, which includes both static and non-static methods.