Which correctly implements the relationships shown in the diagram?

Refer to the Exhibit.

Which correctly implements the relationships shown in the diagram?

Refer to the Exhibit.

Which correctly implements the relationships shown in the diagram?

A.
public class Y {
private Z[] z1and2;
public Y(Z[] z1and2) {
if (z1and2 == null || z1and2.length != 2) {
System.exit(1); // ERROR!
}
this.z1and2 = z1and2;
}

B.
public class Z {
private Y[] y1and2;
public Z(Y[] y1and2) {
if (y1and2 == null || y1and2.length != 2) {
System.exit(1); // ERROR!
}
this.y1and2 = y1and2;
}

C.
public class Z {
private Y y1;
private Y y2;
public Z(Y y1) {
if (y1 == null) System.exit(1); // ERROR!
this.y1 = y1;
}
public Z(Y y1, Y y2) {
this(y1);
this.y2 = y2;
}

D.
public class Y {
private Z z1;
private Z z2;
public Y(Z z1) {
if (z1 == null) System.exit(1); // ERROR!
this.z1 = z1;
}
public Y(Z z1, Z z2) {
this(z1);
this.z2 = z2;
}



Leave a Reply 0

Your email address will not be published. Required fields are marked *