In Java, which of the following statements is/are True ? S1 : The ‘final’…

2018

In Java, which of the following statements is/are True ?
S1 : The ‘final’ keyword applied to a class definition prevents the class from being extended through derivation.
S2 : A class can only inherit one class but can implement multiple interfaces.
S3 : Java permits a class to replace the implementation of a method that it has inherited. It is called method overloading.
Code :

  1. A.

    S1 and S2 only 

  2. B.

    S1 and S3 only

  3. C.

    S2 and S3 only 

  4. D.

    All of S1, S2 and S3

Attempted by 108 students.

Show answer & explanation

Correct answer: A

Correct answer: S1 and S2 only

  • S1: True. A class declared final cannot be extended by other classes, so it cannot be used as a superclass.

  • S2: True. Java allows a class to extend only one class (single inheritance) but implement multiple interfaces.

  • S3: False. Replacing an inherited method's implementation in a subclass is called overriding, not overloading.

Key distinction between overriding and overloading:

  • Overriding: A subclass provides a method with the same name and parameter types as in the superclass to give a new implementation.

  • Overloading: The same class defines multiple methods with the same name but different parameter lists (different number or types of parameters).

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor