Question 59 of 76 from exam 1Z0-808: Java SE 8 Programmer I

Question 59 of 76 from exam 1Z0-808: Java SE 8 Programmer I

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 ("Mercury", 0),
new Planet ("Venus", 0),
new Planet ("Earth", 1),
new Planet ("Mars", 2)

Me

system. out. print1n (planets) ;
system, out. print1n (planets [2]) +
system. out. println (planets [2] .moons) ;

What is the output?

© A) planets
Earth
a

© B) [LPlanets. Planet ;@15db9742
Barth
1

© C) [LPlanets. Planet ;@15db9742
Planets. Planet @6d06d69¢
a

© D) [LPlanets. Planet ;@15db9742
Planets. Planet @6d06d69¢
[LPlanets. Moon; @7852e922

© E) [LPlanets. Planet ;@15db9742
Venus
a

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

C.