Java OOP

 

SHORT ANSWER QUESTIONS

AGGREGATION

 

SOLUTIONS


a) Aggregation

 

b)
A) No aggregation.
B) Aggregation, since a String is an object.
C) Aggregation, since a String is an object.

D) No aggregation, since a byte is a simple variable.  Note that a byte is the same as an int but allows a smaller range of values.  (You do not need to know about bytes for the test.)

E) Aggregation, since we have five Ingredient objects.

F) No aggregation.

 

c)
Primitive data types (such as int, double, byte, boolean) start with a lower case letter.

Object types, which are classes, should always start with a capital letter.

 

d)

First constructor implementation:
p1 = tp1;

p2 = tp2;

 

Second constructor implementation:

p1 = new Point(x1, y1);

p2 = new Point(x2, y2);

 

e)
First constructor implementation

this.n = n;

this.a = a;

 

Second constructor implementation

n = new Name(f, m, l);

a = new Address(n, s, t, p, pc);

 

 

f1)
public String getProvince()

{

   return province;

}

 

f2)
public Address getAddress()
{

   return a;

}

 

f3)
public String getPostalCode()

{

   return a.getPostalCode();

}