hamburger

Which option is false about the Final Keyword?

By BYJU'S Exam Prep

Updated on: September 25th, 2023

(a) A final method cannot be overridden in its subclasses

(b) A final class cannot be extended

(c) A final class cannot extend other classes

(d) A final method can be inherited.

Solution:

A final class cannot extend other classes is false here. A correct answer is option (C). A final class cannot extend to other classes.

Final Class in Java

Final Class in Java employs the final keyword in its declaration, as the name would imply. The final class indicates that the class cannot be expanded, the same as the final keyword in Java helps to restrict the user. A class cannot be an abstract class since we can only establish a final class if it is complete in nature. In Java, all wrapper classes—including String, Integer, and others—are final classes. No subclass can inherit from the final class.

Advantages of final class

  • Because it cannot be extended or inherited by other classes, the final class offers security. Extended classes have a tendency to leak sensitive information about potential users, but final classes keep data elements safe and secure.
  • Since the final class is complete and immutable, external access has no effect on the data elements.

Summary:

Which option is false about the Final Keyword?

A final class cannot extend other classes is false about the final keyword. In Java, the last keyword is used to limit the user. The Java final keyword has a wide range of applications. Variable, method, and class are possible finals.

Our Apps Playstore
POPULAR EXAMS
SSC and Bank
Other Exams
GradeStack Learning Pvt. Ltd.Windsor IT Park, Tower - A, 2nd Floor, Sector 125, Noida, Uttar Pradesh 201303 help@byjusexamprep.com
Home Practice Test Series Premium