GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Concepts  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 61 of 68    Print  
Difference Between Aggregation and Composition
What is the difference between Aggregation and Composition?
(Asked in Polaris Interview for Java Experienced People, on April 11, in Chennai)



  
Total Answers and Comments: 2 Last Update: July 11, 2008     Asked by: khadarzone 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: NIDA REHMAN
 
Association is of different types. Importantnly of three types.

1. I know u as well as so many other people as well. Same for you. You also know so many people.This kind of relationship is depicted as simple Association in UML.

This is always characterised by "has a" relationship. Like I have your reference. You have mine reference. Both or none.

2. I am not complete without you. You make me complete. Example a music system consists of sound box, CD player, graphic equalizer etc.

So in other words we may say, a music system is aggregation of CD player, casette player, graphics equalizer, sound box etc.

Or music system object has aggregation relationship with each of the things mentioned above.

3. I am not complete without you. And you dont exist outside me.

Example could be a tree?

Branches, leaves, fruits dont exists outside it? If tree dies everything dies.

This is strongest form of association and called composition relationship.

Another examples could be relationship between a house and its rooms. Rooms dont exist outside a house? Same room cannot be shared across two houses? And all the rooms persishes if the house collapses.

Keeping it Simple,
Aggregation or Composition depends up on life time of the child object.
If the child object cannot exist beyond the lifetime of its parent then the relationship is composite(Strong relationship)
If the child object can exist beyond the lifetime of its parent, then the relationship is aggregtion.However, at a particular moment the child object can be controlled only by a single parent(ie. Unshared), and it is the responsibility of the parent object to transfer the control of the child object to some other instance while its destruction.

Above answer was rated as good by the following members:
Gunvant
June 02, 2008 06:35:18   #1  
NIDA REHMAN Member Since: June 2008   Contribution: 1    

RE: Difference Between Aggregation and Composition
Association is of different types. Importantnly of three types.

1. I know u as well as so many other people as well. Same for you. You also know so many people.This kind of relationship is depicted as simple Association in UML.

This is always characterised by "has a" relationship. Like I have your reference. You have mine reference. Both or none.

2. I am not complete without you. You make me complete. Example a music system consists of sound box CD player graphic equalizer etc.

So in other words we may say a music system is aggregation of CD player casette player graphics equalizer sound box etc.

Or music system object has aggregation relationship with each of the things mentioned above.

3. I am not complete without you. And you dont exist outside me.

Example could be a tree?

Branches leaves fruits dont exists outside it? If tree dies everything dies.

This is strongest form of association and called composition relationship.

Another examples could be relationship between a house and its rooms. Rooms dont exist outside a house? Same room cannot be shared across two houses? And all the rooms persishes if the house collapses.

Keeping it Simple
Aggregation or Composition depends up on life time of the child object.
If the child object cannot exist beyond the lifetime of its parent then the relationship is composite(Strong relationship)
If the child object can exist beyond the lifetime of its parent then the relationship is aggregtion.However at a particular moment the child object can be controlled only by a single parent(ie. Unshared) and it is the responsibility of the parent object to transfer the control of the child object to some other instance while its destruction.

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
July 11, 2008 03:00:17   #2  
hafeez_munawar Member Since: July 2008   Contribution: 2    

RE: Difference Between Aggregation and Composition
Aggregation:
In aggregation one object is composed of multiple objects and every object is useless without the relationship. Suppose there is a car object so car object is useless without the tyre or steering object and steering object is useless without car. This type of relationship is called Aggregation.

Compostion:
One object is composed of several objects in this type of relationship every object has its own existance

 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : Data hiding is done by using access specifier and data encapsulation is wrapping of data which use default specifier. ...
Read Answers (18) | Asked by : ramaprasad

Latest Answer : When you create a custom type (class) in any language, that class in OOP is called Object and when you create an istance of this class just as we create instance of built-in types e.g. (int a,float b) it is called instance of the object. ...

Latest Answer : Abstraction:Denotes the essential properties and behaviour of an object that differentiate it from other objects. e.g: We use objects but we're not concerned with whats going behind the scene.Encapsulation:Its a process of binding the data and its behaviour ...
Read Answers (8) | Asked by : girija

Latest Answer : This is method of thinking to resolve the problem ( implimenting the applicaiton using software languages).             - POP : Procedure thinking   ( modular approach of solve the problem)         -OOP : Object Thinking ( object ...
Read Answers (4) | Asked by : Manpreet Kaur

Latest Answer : DOS: single process, single thread Windows: multiple process, multiple threads ...
Read Answers (2) | Asked by : nandhini

Latest Answer : arulkumar:  No, Void pointer is a pointer it is automatically type casted, we can assign to any pointer. But NULL pointer is a pointer which holds 0 (zero) as its content. (i.e) It doesn't pointing anything.   ...
Tags : Pointer

Latest Answer : Implicit cursor we have to open and close for  it's usage.It will not automatically close.Explicit cursor will automaticlly open and close.eg: for x in (exp.)       where x is the cursor name exp. is an expression.This ...

Latest Answer : in ++*p firstly it will move to the incremented address of the pointing variable &from there the value will pick up the value of the variable, then it will assign to the corresponding variable or to itself.  In (*p)++ it will first assign value and ...
Read Answers (3) | Asked by : vijayn

What is the difference between docking container and splitter container?What is tree display?Explain with sample prgms.
View Question | Asked by : karthihassan

What is the difference between Aggregation and Composition?(Asked in Polaris Interview for Java Experienced People, on April 11, in Chennai) 
Latest Answer : Aggregation:In aggregation , one object is composed of multiple objects and every object is useless without the relationship. Suppose there is a car object, so car object is useless without the tyre or steering object, and steering object is useless without ...


 Sponsored Links

 
Related Articles

Concepts of Object-Oriented Programming

Object Oriented JavaScript In this chapter you ll learn about OOP Object Oriented Programming and how it relates to JavaScript As an ASP NET developer you probably have some experience working with objects and you may even be familiar with concepts such as inheritance However unless you re already a
 

OOPS Tutorials

Object oriented programming OOP is a computer science term used to characterize a programming language that began development in the 1960’ s The term object oriented programming’ was originally coined by Xerox PARC to designate a computer application that describes the methodol
 

SOA Concepts

SOA Concepts Today the concept of Service Oriented Architecture has become ubiquitous Evidence from recent years establish that SOA is not just about hype but a part of every major Business environment The truth is Service Oriented Architecture can be beneficial to Business only when it is utilized
 

What is Data Aggregation

In Data Aggregation, value is derived from the aggregation of two or more contributing data characteristics.   Aggregation can be made from different data occurrences within the same data subject, business transactions and a de-normalized database and between the
 

What is Aggregation

In the broadest sense of the word, aggregation means collecting and combining of data horizontally, vertically and chronologically and then expressed in summary form to be used for statistical analysis. In the more technical sense, aggregation is a special kind association that specified a part of w
 

What is difference between call by value and call by reference in function?

The arguments passed to function can be of two types 1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 main() { int x=50, y=70; interchange(x,y); printf(“x=%d y=%d”,x,
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

WinRunner Programming Concepts

If you want to create WinRunner scripts that are highly efficient, there are important programming concepts that you will want to become familiar with. Understanding these concepts will provide you with a large number of key benefits. In addition to understanding these concepts, you must also learn
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape