Lakhyadeep Sen’s Post

Inheritance is one of the core ideas in object oriented programming that allows a class to reuse the properties and behaviour of another class. Instead of rewriting the same logic again, a new class can extend an existing one. Things that became clear : • inheritance allows one class to acquire the properties and methods of another class • the class that provides the features is called the parent or base class • the class that inherits those features is called the child or derived class • the extends keyword is used to create this relationship in Java • it helps promote code reuse and cleaner program structure A simple example helps illustrate the idea : class Person { String name; int age; } class Student extends Person { int marks; } In this case the Student class automatically gets the name and age properties from the Person class while also adding its own data. This structure helps avoid repeating code and keeps related behaviour organized through class relationships. #java #oop #programming #learning #dsajourney

To view or add a comment, sign in

Explore content categories