“Is-a” relationship is basic element of OOP.
This functionality is helps to achieve re-useabilty in our code.
Basically “Is-a” relationship also called parent-child relationship between two classes.
We divide our code int o classes such that common functionality kept in one class called parent class and remaining in child class which inherits the parent class.
A little JAVA example to achieve “is-a” relation ship is described below
public class Animal{ } public class Mammal extends Animal{ } public class Reptile extends Animal{ } public class Dog extends Mammal{ }
“extends” keyword used for inheritance in java.
The post How to achieve “is-a” relationship? appeared first on Programming Baba.