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                      
tip   To Refer this Site to Your Friends   Click 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
What is the is a and has a relation ship in oops concept in
java?
 Question Submitted By :: Sandya
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the is a and has a relation ship in oops concept in java?
Answer
# 1
The relationships are the structure of the object. has-a
relationship can be described in Java code as member fields.
is-a relationship can be described in Java keyword extends.
The is-a relationship has an inheritance feature (like
"extends" or "implements") and has-a relationship has an
encapsulation feature (like private or protected modifier
used before each member field or method).

Let's look at one example. Translate the following perfect
sentences into Java code.

   1. Pizza is a food. A Pizza has ingredients, a cost, and
a price.

       
      public class Pizza extends Food //is-a relationship
      {
         int ingredients;//has-a relationship
         double cost;
         double price;
         ....
      } 
 
Is This Answer Correct ?    12 Yes 2 No
Sandya
 
  Re: What is the is a and has a relation ship in oops concept in java?
Answer
# 2
Ya correct there is relation ship. that is the main concpt 
in java
 
Is This Answer Correct ?    4 Yes 3 No
Gopid123
[BRADY]
 
 
 
  Re: What is the is a and has a relation ship in oops concept in java?
Answer
# 3
is a nothing but inheritance and has a nothing but extends
 
Is This Answer Correct ?    0 Yes 9 No
Guest
 
  Re: What is the is a and has a relation ship in oops concept in java?
Answer
# 4
OOOOOO!NOooooooooo.

is a relationship is (inheritence)

has a relationship is (composition or Assocation)

Example:
 Has a relation

public class Address
{
String street;
String city;

.......

}

public class Person
{
String name;
Address address;    //has a relationship
}
 
Is This Answer Correct ?    9 Yes 0 No
Raghava
 
  Re: What is the is a and has a relation ship in oops concept in java?
Answer
# 5
Yea you right.
is-a represent the inheritence
and
has-a represents the delegation/association
for example
Chair is a type of Furniture
and
Furniture has a relationship with chair
 
Is This Answer Correct ?    6 Yes 0 No
Vashisht Rakesh
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Which containers may have a MenuBar?  1
java can provide security ,how can provide? IBM3
What modifiers are used with a top level class?  2
what is jms? features of jms CTS1
what is difference between front controller and action servlet?  2
Hai all I want to print given array in reverse order Ex: int a[]={1,2,3,4,5};display this array in reverse order.  2
What is the difference between a Window and a Frame?  1
What is a default package ?  7
Explain Stream Tokenizer?  3
how to compile jsp? Logica-CMG3
what is bytecode ?explain in detail and watz the difference between bytecode and machine code? Lucent3
What is the return type of read()?  2
suppose in a class there is a code like this: { Set hs=new Hashset(); hs.add(new Emp("kathy",1000)); hs.add(new Emp("kathy",2000)); } how can u avoid the above code in your class as set won't allow duplicate objects?  2
What is a void return type?  2
I have a Arraylist object, it has duplecate values also. Now question is i want delete duplecate data in that objet with out using Set? Aricent5
where lives in jvm  3
What is the difference between static and non-static variables?  2
What are the standards to place package statement within a source code file?  1
different types of threads? TCS7
What is the ResourceBundle? Elementus-Technologies2
 
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