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 keyword is used in Java to make a class member unable to be changed?

  1. Yes

  2. No

  3. Only if it's static

  4. Only in inner classes

The correct answer is: Yes

In Java, if a method is marked as final, it means that it cannot be overridden in any subclass. This is to prevent subclasses from changing the functionality or implementation of the final method. Therefore, the correct answer is A as all methods in a base class, including final methods, can be inherited by a derived class but they cannot be overridden. Incorrect answers include B, as stated previously, final methods cannot be overridden, and C and D, as the rules for overriding final methods also apply to static and inner classes, meaning they cannot be overridden either.