Inheritance Reviewer
Inheritance Reviewer
Inheritance Reviewer
java
System.out.println("Dog Details:");
dog.display();
System.out.println("\nCat Details:");
cat.display();
Animal.java
// Attributes of an animal
// Constructor
this.name = name;
this.age = age;
// Getter methods
return name;
return age;
Dog.java
// Constructor
super(name, age);
this.breed = breed;
@Override
super.display();
}
Cat.java
// Constructor
super(name, age);
this.color = color;
@Override
super.display();
Output: