Java · Question 3 · Easy

Which Java keyword, when applied to a class, prevents any other class from extending it?

  1. static
  2. final
  3. private
  4. abstract
Answer and explanation

Answer: B. final

Explanation: A final class cannot be subclassed (java.lang.String is an example). abstract means the opposite: the class is meant to be extended.

Previous: What will be the output of the following Java program? · Next: What will be the output of the following Java program?

Practise java

Try a fresh set of java questions with an explanation after every answer, free and without signing up: Java practice. Or sit a full placement mock test.

More java questions

More technical & programming practice

Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge