Single Inheritance in Java

7 Jul 2025 | 4 min read

In Java, inheritance enables a class to adopt behaviors and functions from another class. The class from which the functionalities and behaviours are inherited is known as the base class or parent class or superclass. The receiver class is often known as a child class, or subclass or derived class.

To read more Inheritance in Java

It establishes a distinct hierarchy and uses the parent class's properties and functions. An "IS-A" relationship, sometimes referred to as a parent-child relationship, can be shown via inheritance.

Single Inheritance

In single inheritance, a derived class inherits all the methods and properties from a single-parent class or base class. Java provides a keyword named extends that is used to inherit properties and methods from a class. Let's understand it through a figure.

Single Inheritance in Java

In the above figure, the child class B inherits all the properties and methods from a single-parent class A.

Syntax:

Single Inheritance Example

Output:

 barking... eating... 

Advantages and Disadvantages of Single Inheritance

Advantages

  • Maintaining a clear hierarchy is aided by single inheritance. As a result, it facilitates the understanding and management of the code.
  • By inheriting properties and methods from the parent class, the child class avoids writing duplicate code. Consequently, it prevents development time inefficiency and avoids code
  • The fields and methods of the parent class can be used directly by the child class. Thus, it can help you write repetitive code faster and with less effort.
  • The child class can add its special methods and attributes to inheritable properties. Consequently, it can provide a greater degree of abstraction.

Disadvantages

  • Only a parent class may be inherited by a class. It restricts the possibilities for creating intricate linkages or behaviors.
  • Not every piece of code can be easily categorized into a single inheritance hierarchy. It may lessen the chances for efficient code reuse.
  • It can cause ambiguity or unexpected behavior in the program if inherited methods have the same names but carry out distinct operations.

Real-World Uses of Java Single Inheritance

  • Banking Systems: A BankAccount class is a class from which a SavingsAccount class can inherit. It makes use of standard banking features.
  • Platforms for Online Shopping: A Customer class can extend a User class. This is due to the fact that it inherits facilities for managing profiles and logins.
  • Educational Systems: A Person class can pass on inheritance to a Student class. As a result, it can include student-specific information like grades and classes.
  • Vehicle Management: Start() and stop() are two methods that a Car class can reuse by extending a Vehicle class.
  • Appliance Control: An Appliance class can pass on power control features to a WashingMachine class.

Single Inheritance MCQs

1. Which of the following best describes Single Inheritance in Java?

  1. A class can inherit from multiple classes.
  2. A class can inherit from only one superclass.
  3. A class cannot inherit from any class.
  4. A class can inherit from interfaces only.
 

Answer: B

Explanation: Single inheritance in Java refers to a class's ability to extend just one direct superclass at a time. In addition to avoiding the complexity of various inheritance issues, such as the Diamond Problem, this helps Java maintain a simple and unambiguous hierarchy.


2. Which keyword is used in Java to implement Single Inheritance?

  1. implements
  2. super
  3. extends
  4. inherit
 

Answer: C

Explanation: A subclass in Java can inherit attributes and behaviors from a single superclass by using the extends keyword. A derived class can reuse code from its parent class thanks to Single Inheritance, which is based on this.


3. Which of the following is true about method access in Single Inheritance?

  1. Private methods of the superclass are inherited directly.
  2. Protected and public methods of the superclass are accessible in the subclass.
  3. Static methods cannot be accessed.
  4. Subclass cannot override methods of the superclass.
 

Answer: B

Explanation: A subclass can access the public and protected members of its superclass through single inheritance. Although private members cannot be reached directly, they can be accessed through protected or public getters.


4. What is inherited in single inheritance?

  1. Only constructors
  2. Only static methods
  3. Non-private fields and methods
  4. Only final methods
 

Answer: C

Explanation: A subclass inherits all accessible (non-private) fields and methods from its superclass.


5. Which of the following is NOT true about single inheritance?

  1. It promotes code reuse
  2. It allows a class to inherit from multiple classes
  3. It supports method overriding
  4. It helps in hierarchical class design
 

Answer: B

Explanation: Java does not allow a class to inherit from more than one class-only interfaces can be used for multiple inheritance.