Oracle
1Z0-850 · Question #32
1Z0-850 Question #32: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-850 to reveal the answer and full explanation for question #32. The question stem and answer options stay visible for context.
Question
Given:
- class X {
- private Y y;
- public X(Y y) { this.y = y; }
- }
- class Y {
- private X x;
- public Y() { }
- public Y(X x) { this.x = x; }
- } The instance variable y is intended to represent the composition relationship "X is composed of Y". Which code correctly maintains this meaning?
Options
- AX x1 = new X(new Y()); X x2 = new X(new Y());
- BX xx = new X(null); Y y1 = new Y(xx); Y y2 = new Y(xx);
- CX x1 = new Y(); X x1 = new Y(yy); X x2 = new Y(xy);
- DY y1 = new Y(new X(null)); Y y2 = new Y(new X(null));
Unlock 1Z0-850 to see the answer
You've previewed enough free 1Z0-850 questions. Unlock 1Z0-850 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.