ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
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?
 Question Submitted By :: Maria
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
class LandAnimal 
{
//some code here

}
class WaterAnimal extends LandAnimal
{
//soma code here
}
class Animal extends landAnimal
{
// here we can access properties  both class
}
 
Is This Answer Correct ?    2 Yes 11 No
Vikneswarank
[Jadian]
 
  Re: 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
# 2
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 ?    4 Yes 7 No
Abdul
 
 
 
  Re: 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
# 3
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 ?    13 Yes 0 No
Bhaskr Reddy
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is the use of anonymous inner classes ? HCL8
How the elements are organized in GridLayout?  1
can we declare private class in java file?  6
what is polymorphism?  2
What is Collection interface? Zensar1
what is the Use of throws exception?  2
In which way does a Primitive data type is passed ? Sun-Microsystems2
1.what is the exact difference between applet and frame? 2.Do we use main method in frames?  2
What is a reflection package?  2
what is abstract method with example? Virtusa5
what is the replacement for GOTO in java? CTS2
Why all programming languages have main as a execution starting point?  2
What is unicode?  2
What are the similarities between an array and an ArrayList?  2
What we have to do, when we don't want to implement all methods of an interface?  2
how to connect one jsp page to another jsp page???? Symphony4
how you will prevent method overriding? HCL4
What is an enumeration class?  2
where u use Abstraction and Interface in real time Sonata2
How do you set security in applets? Wipro1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com