
In Java OOP (Object-Oriented Programming), Inheritance is one of the most important concepts. It allows one class to acquire the properties and behaviors of another, reducing code duplication and improving reusability.
📘 Concept Notes
🔑 What is Inheritance?
- Inheritance is the process where one class (child/subclass) derives properties and methods from another class (parent/superclass).
- Symbolically:
⚙️ Types of Inheritance in Java (ECET Focus)
- Single Inheritance
- One child class inherits from one parent class.
- Example:
class Animal {
void eat() { System.out.println("Eating..."); }
}
class Dog extends Animal {
void bark() { System.out.println("Barking..."); }
}
public class TestSingle {
public static void main(String[] args) {
Dog d = new Dog();
d.eat(); // Inherited from Animal
d.bark(); // Own method
}
}
- Multilevel Inheritance
- A class inherits from another class, and then another class inherits from it.Example:
class Animal {
void eat() { System.out.println("Eating..."); }
}
class Dog extends Animal {
void bark() { System.out.println("Barking..."); }
}
class Puppy extends Dog {
void weep() { System.out.println("Weeping..."); }
}
public class TestMultilevel {
public static void main(String[] args) {
Puppy p = new Puppy();
p.eat(); // From Animal
p.bark(); // From Dog
p.weep(); // From Puppy
}
}
📐 Formula – Class Relationship
If means “Class B inherits Class A”, then:
- Single Inheritance:
- Multilevel Inheritance:
🛠 Advantages of Inheritance
- Code reusability.
- Method overriding and polymorphism support.
- Easier maintenance and reduced redundancy.
🔟 10 Expected MCQs – ECET 2026
Q1. Inheritance in Java is achieved using keyword:
A) inherit
B) extends
C) implements
D) super
Q2. In single inheritance, how many parent classes are directly involved?
A) 1
B) 2
C) 3
D) Unlimited
Q3. In multilevel inheritance, class C inherits properties from:
A) Only class A
B) Only class B
C) Both A and B
D) None
Q4. Which of the following is NOT true about inheritance?
A) Reduces redundancy
B) Provides reusability
C) Makes maintenance difficult
D) Supports method overriding
Q5. Symbolically, single inheritance can be represented as:
A)
B)
C)
D) None
Q6. Which inheritance type is not supported directly in Java (but via interfaces)?
A) Single
B) Multilevel
C) Multiple
D) Hierarchical
Q7. Which keyword is used to call parent class methods inside child class?
A) this
B) super
C) parent
D) base
Q8. If class C extends class B, and class B extends class A, this is:
A) Multiple inheritance
B) Multilevel inheritance
C) Hierarchical inheritance
D) None
Q9. The main advantage of inheritance is:
A) Increased redundancy
B) Reusability
C) More memory usage
D) None
Q10. In Java, constructors of parent class are:
A) Not inherited
B) Automatically invoked when subclass is created
C) Must be explicitly called
D) None
✅ Answer Key
Q.No | Answer |
---|---|
Q1 | B |
Q2 | A |
Q3 | C |
Q4 | C |
Q5 | B |
Q6 | C |
Q7 | B |
Q8 | B |
Q9 | B |
Q10 | B |
🧠 Explanations
- Q1 → B: Inheritance uses
extends
. - Q2 → A: Only one parent class in single inheritance.
- Q3 → C: In multilevel, C inherits both A and B indirectly.
- Q4 → C: Inheritance simplifies maintenance.
- Q5 → B: Single inheritance: A → B.
- Q6 → C: Multiple inheritance is not supported by classes in Java.
- Q7 → B:
super
is used for parent access. - Q8 → B: A → B → C = multilevel.
- Q9 → B: Inheritance allows reusability.
- Q10 → B: Parent constructor invoked automatically.
🎯 Why Practice Matters
- Inheritance is a core Java OOP topic.
- ECET exams test basic code snippets and definitions.
- With practice, 2–3 marks are guaranteed.