Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / bhaskr reddy

interface LandAnimals {

class LandAnimal {

// define the Land Animal prperties
}
}

interface WaterAnimals{

class WaterAnimal{

// define the Water Animal prperties
}
}

Now define the "Animal" class by implementing the two
interfaces(WaterAnimals and LandAnimals ).

Note1 : Java supports defining the class inside an
interface.

Note 2 : In the previous answer somebody has defined two
seperate classes for WaterAnimal and Land animal
and his LandAnimal extends WaterAnimal then LandAnmal
becomes the Water animal this is poor object orientation.

Is This Answer Correct ?    18 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define how objects are stored in java?

1018


How do you declare an empty string?

1026


What is meant by javabeans?

1054


How to declare objects of a class ?

1033


What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?

929


Give example to differentiate between call by value and call by reference.

1003


What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?

1065


Can a boolean be null java?

946


who can i handle multiple client in RMI

1861


Is main a function?

994


Explain about the performance aspects of core java?

1011


What is string pooling concept?

1025


What java ide should I use?

965


what do you mean by classloader?

1049


What are peerless components?

1055