Please support our Java advertiser: Lunarpages Java Web Hosting
![]() |
•
•
Join Date: Aug 2005
Location: Socialist Republic of Boulder
Posts: 216
Reputation:
Rep Power: 4
Solved Threads: 6
•
•
Join Date: Sep 2005
Posts: 51
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
•
•
Originally Posted by kingmahesh
Composition (called “has-a�) is a relationship between classes where one class has a data member that is an instance of the other class, such as “a car has a tire�. When creating a program, you need to choose whether to relate classes through inheritance or composition.
king
hi all,
with regard to composition and inheritance, there is a term named as polymorphism...is it related to the above? so infact, composition is inheritance, but in my class, we usually called the method as inheritance and the sub-classes have the attributes and properties of the main class. i mean from the main-class, u will have the sub-classes and the relationship is called inheritance. hope that what i understand can be of use to you. cheers!
•
•
Join Date: Aug 2005
Location: Socialist Republic of Boulder
Posts: 216
Reputation:
Rep Power: 4
Solved Threads: 6
•
•
•
•
Originally Posted by tristan17
hi all,
with regard to composition and inheritance, there is a term named as polymorphism...is it related to the above? so infact, composition is inheritance, but in my class, we usually called the method as inheritance and the sub-classes have the attributes and properties of the main class. i mean from the main-class, u will have the sub-classes and the relationship is called inheritance. hope that what i understand can be of use to you. cheers!
Polymorphic behavior is more of a "is-a" relationship then a "has-a" relationship. A Circle is a type of Shape and should be able to be viewed as a Shape and have all the same behavior (methods) as Shape. Polymorphism is accomplished by both inheritance and interfaces in java.
Regards,
Nate
![]() |
Similar Threads
Other Threads in the Java Forum
- composition (C++)
- OOP char [8] to char (C++)
Other Threads in the Java Forum
- Previous Thread: how to include a .so file in c++ dll?
- Next Thread: how the area is calculated
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode