Oracle
1Z0-809 · Question #144
1Z0-809 Question #144: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #144. The question stem and answer options stay visible for context.
Question
Given the following code for a planet object:
public class Planet {
public String name;
public int moons;
public Planet(String name, int moons) {
this.name = name;
this.moons = moons;
}
}
And the following main method:
public static void main(String[] args) {
Planet[] planets = new Planet[3];
planets[0] = new Planet("Mercury", 0);
planets[1] = new Planet("Venus", 0);
planets[2] = new Planet("Earth", 1);
System.out.println(planets[0]);
System.out.println(planets[1].moons);
System.out.println(planets[2].moons);
}
What is the output?Options
- A[LPlanets.Planet;@15db9742 0 1
- BPlanets Venus 0
- C[LPlanets.Planet;@15db9742 Earth 0
- D[LPlanets.Planet;@15db9742 0 1
- E[LPlanets.Planet;@15db9742 [LPlanets.Planet;@8d06d69c [LPlanets.Planet;@7a523e22
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 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.