This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Aggregation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Aggregation" Watch "Aggregation" New topic
Author

Aggregation

Isabel Wanderley
Ranch Hand

Joined: Aug 24, 2002
Posts: 42
Hi...
I wanna know what I have to know about aggregation for 1.4 SCJP Tkz!
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Could you be more precise in your question, please?
Aggregation is usually known as a has_a relationship.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Salima Lalani
Ranch Hand

Joined: Aug 15, 2002
Posts: 59
Hi,
Aggregation is a relationship between whole and part. But what exactly will be asked on this topic in exam?
Pls. Reply
Thanks
Salima
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Hi there:
You can implement inheritance in two ways:
a. by extending a super class. for example:
class LivingBeing { }
class Man extends LivingBeing { }
class Woman extends LivingBeing { }
This is sort of "is a" relationship.
b. by aggregating other classes. for example:
class HumanBeing {
Man M = new Man();
Woman W = new Woman();
}
This is sort of "has a" relationships.
The questions on aggregating revolves around how do you access the methods and fields belonging to
Man and Woman classes from the objects of HumanBeing class.
Hope this helps.
Barkat
[ August 29, 2002: Message edited by: Barkat Mardhani ]
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
In the exam SCJP1.2 you can be asked to "model" a given example about concepts. Something like a "computer" class and several "O.S." classes.
You are given answers to choose between implementations using inheritance or composition.
--------------------
Barkat,
agregation is used to implement inheritance?
Maybe you mean that agregation can be used to get some of the benefits of inheritance: to add funtionality to a class.


SCJP2. Please Indent your code using UBB Code
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Hi Jose:
Original posted by Jose:
Barkat,
agregation is used to implement inheritance?
Maybe you mean that agregation can be used to get some of the benefits of inheritance: to add funtionality to a class.

It is very difficult to get to the exact intendended meaning of the authur when they use words like "aggregation" as different people mean
different things.
I think there are two sheds of meaning for aggregation:
1. within the context of a class, otherwise known
as composition, which is what I was trying to get
at in my first post. Here is a quote from Bruce Eckel's Thinking in Java

The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this “creating a member object.” Your new class can be made up of any number and type of other objects, in any combination that you need to achieve the functionality desired in your new class. Because you are composing a new class from existing classes, this concept is called composition (or more generally, aggregation). Composition is often referred to as a “has-a” relationship, as in “a car has an engine.”

2. within the context of objects i.e. containers holding objects could be termed as aggretion.
Therefore, to answer the question originally posted in this thread: aggregation questions in exam could be related to composition and containers.
Thanks
Barkat
 
GeeCON Prague 2014
 
subject: Aggregation