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 / abdul

class WaterAnimal
{
// code
}
class LandAnimal extends WaterAnimal
{
//This class has WaterAnimal properties
}
class Animal extends LandAnimal
{
//This class has both LandAnimal and WaterAnimal properties
}

Is This Answer Correct ?    10 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How we can generate random numbers in java?

612


What is variable and its types?

547


When does a class need a virtual destructor?

533


What about member inner classes?

636


What is hash code collision?

597






What is map and hashmap in java?

626


What is function declaration?

534


Mention some features of java?

546


How does map works in java?

524


What are design patterns and please explain?

576


What is the java idl system?

587


How can the checkbox class be used to create a radio button?

514


Is zero a positive integer?

537


What is the difference between JDBC 1.0 and JDBC 2.0?

2716


What is static block?

595