what is inheritance

Inheritance in Java

Inheritance is a fundamental concept in Java that allows a new class (called a subclass or child class) to inherit properties and behaviors (fields and methods) from an existing class (called a superclass or parent class).

Key Points:

  1. Reusability: You can reuse existing code, reducing redundancy.
  2. Hierarchical Structure: Helps in organizing code with a clear hierarchical structure.
  3. Syntax:
    • Use the extends keyword for inheritance.

Leave a Reply

Your email address will not be published. Required fields are marked *