java is a vs has a code example
Example 1: What is IS-A relationship in java
‘is a’ relationship is also known as inheritance. We can implement
‘is a’ relationship or inheritance in java using extends keyword.
The advantage of inheritance or is a relationship is reusability of code
instead of duplicating the code.
Ex :
Motor cycle is a vehicle
Car is a vehicle
Both, car and motorcycle extends vehicle.
Example 2: is a relationsiop in java
public class Actress extends Person { public String readScript(String movie) { return "Reading the script of " + movie; }