There are 2 classes, 1 LandAnimal and another WaterAnimal.
There is another class Animal which wants to have the
properties of both LandAnimal and WaterAnimal. How will you
design this situation?
Answer Posted / sahaj
[note:landanimal and wateranimal both behave as base class
and the other one behave as derieved class]
#include<iostream.h>
#include<conio.h>
class landanimal
{
void print();
{
cout<<"this is base class"<<endl;
}};
class wateranimal
{
void display();
{
cout<<"this is another base class"<<endl:
}};
class animal:public landanimal,public wateranimal
{
void disp();
{
cout<<"this is derieved class"<<endl;
}};
void main()
{
animal a;
a.print();
a.display();
a.disp();
getch();
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the memory leak in java?
What is a cup of java?
What does java edition mean?
What are the different types of java?
Why arraylist is used in java?
Why are arrays useful in java?
What are the topics in advance java?
Write a program in java to establish a connection between client and server?
Is a method a function?
Which collection does not allow duplicates in java?
How are destructors defined in java?
Define max and min heap, also the search time of heap.
What is a layout manager and what are different types of layout managers available in java awt?
You're given a Boolean 2D matrix, can you find the number of islands?
What is java english?