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


Please Help Members By Posting Answers For Below Questions

Is string a data type in java?

590


Which object oriented concept is achieved by using overloading and overriding?

551


Why vector class is used?

536


Have you ever used hashtable and dictionary?

569


What are strings in physics?

539






What are mutable classes?

521


What is unicode full form?

548


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

621


Can we extend singleton class?

527


What is java autoboxing?

532


Explain about varargs in java?

578


Can we override constructors?

541


What is concurrent hashmap and its features?

521


Explain JMS in detail.

612


What is jar?

629