0
8.5kviews
Create an Animal class, with attributes name, and age. Create classes Dog2, Cat2, Fish2, and Bird2 to inherit from the Animal class. Create PetOwner2 class to test the inheritance and polymorphism.
1 Answer
0
587views

Java Inheritance

  • Inheritance is one of the main features of OOP that allows us to create a new class from an existing class.

  • Due to inheritance, it is possible to inherit attributes and methods from one class to another.

  • Inheritance can create two classes as follows:

    • Subclass - The new …

Create a free account to keep reading this post.

and 5 others joined a min ago.

Please log in to add an answer.