Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Differentiation between Inheritance and Aggregation

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 30-01-2010
Member
 
Join Date: Dec 2009
Posts: 32
Differentiation between Inheritance and Aggregation
  

Hi All,

I have too many confusion about the various java concepts. I have some knowledge about the Inheritance. But the thing is that I don't know anything about the difference between Inheritance and Aggregation. I know inheritance is used for to implement the re-usability of program code. But but not able to get the differentiation between Inheritance and Aggregation. I wonder if you are able to help me to understand this.

Reply With Quote
  #2  
Old 30-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,843
Re: Differentiation between Inheritance and Aggregation

The concept of inheritance is one of the most important concept of object oriented programming because it irreversibly determines the manner in which a code Java is written. Inheritance is a mechanism to create a new class from an existing class in him uttering his properties and methods. In this way, the inherited classes form a hierarchy descending on top of which is the base class.
Reply With Quote
  #3  
Old 30-01-2010
Member
 
Join Date: Jan 2008
Posts: 1,512
Re: Differentiation between Inheritance and Aggregation

It is sometimes difficult to choose between classical association and aggregation. An aggregation is a special relationship between an object and several objects the component. An aggregation is sometimes called aggregation of reference as opposed to aggregation by value (also called composition). An aggregation is represented by an empty diamond positioned on the side of the compound (the class representing the whole).
Reply With Quote
  #4  
Old 30-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,946
Re: Differentiation between Inheritance and Aggregation

A composition is an aggregation constraint. The additional constraint compared to a traditional aggregation is relative to the lifetime of objects. The composition implies that components are dependent existence of the compound. A composition is also called aggregation by value. A "implements" Java is represented by an inheritance relationship but with a dotted arrow. To define a new class, we only need to inherit the an existing class and add new methods.
Reply With Quote
  #5  
Old 30-01-2010
Member
 
Join Date: May 2008
Posts: 2,004
Re: Differentiation between Inheritance and Aggregation

Following is example of Aggregation:
Quote:
class Ai (
private Bi objBi;
...
)
//If Class Bi is used primarily in the context of Ai, you can also opt for an inner class:
public class Ai
(
private Atti1;
private class Bi
(
att_de_Bi_1 string;
)
)
Reply With Quote
  #6  
Old 30-01-2010
Member
 
Join Date: May 2008
Posts: 2,286
Re: Differentiation between Inheritance and Aggregation

When instantiating a class, it inherits all properties and methods of its super-class, which itself inherits a possible super-class. By default a class inherits from the super-super-class "named Object. To inherit a class from a super-class, Java provides the keyword 'extends', The main job of the Java programmer is to design a class hierarchy, that is to say, organizing classes such as the properties and methods common to several classes are placed in a super-class.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Differentiation between Inheritance and Aggregation"
Thread Thread Starter Forum Replies Last Post
What is the difference between Single inheritance and multilevel inheritance? Venugopala Software Development 3 08-01-2011 05:32 AM
Differentiation between Containment and Inheritance Bottlenecked Software Development 5 21-01-2010 08:59 AM
Differentiation between WAN and LAN Dolsy_bendal Networking & Security 4 30-11-2009 09:46 AM
SQL error of aggregation Bull50 Software Development 2 09-05-2009 11:37 AM
Link Aggregation - Bundling of interfaces Willi Networking & Security 4 10-04-2009 03:15 PM


All times are GMT +5.5. The time now is 03:03 PM.