Create two classes named Mammals and SeaAnimal. Create another class named Whale which inherits both the above classes. Now, create a function in each of these classes which prints "I am mammal" in class Mammals, "I am a marine animal” in class Marine and "I belong to both the categories: Mammals as well as Marine Animals" in class Whale. Now, create an object for each of the above class in main function and try calling. 1 - function of Mammals by the object of Mammal 2 - function of SeaAnimal by the object of SeaAnimal 3 - function of Whale by the object of Whale
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Q1: Create two classes named Mammals and SeaAnimal. Create another class named Whale which
inherits both the above classes. Now, create a function in each of these classes which prints "I am
mammal" in class Mammals, "I am a marine animal” in class Marine and "I belong to both the
categories: Mammals as well as Marine Animals" in class Whale. Now, create an object for each of the
above class in main function and try calling.
1 - function of Mammals by the object of Mammal
2 - function of SeaAnimal by the object of SeaAnimal
3 - function of Whale by the object of Whale
4 - function of each of its parent by the object of Whale
Step by step
Solved in 3 steps with 1 images