Inheritance is one of the core concepts of Object-Oriented Programming (OOP) in Java that allows one class to acquire the properties and behaviors of another class. It promotes code reusability by enabling a child class to inherit fields and methods from a parent class.
A Dog is an Animal. Instead of writing common properties and behaviors again, the Dog class can inherit them from the Animal class.
class Animal {
void eat() {
System.out.println("Animal is eating");
}
}
class Dog extends Animal {
void bark() {
System.out.println("Dog is barking");
}
}
public class Demo {
public static void main(String[] args) {
Dog dog = new Dog();
dog.eat();
dog.bark();
}
}Animal is eating
Dog is barking
A concise interview answer is
Inheritance is an OOP feature that allows one class to acquire the properties and methods of another class. It promotes code reuse, reduces duplication, and helps establish an 'is-a' relationship between parent and child classes using the extends keyword.
Last updated: 11 November 2026
Previous question: How do you create an immutable class in Java?
Next question: Can a class extend itself in Java?