Given this code for a Planet object:
What is the output?
A.
B.
C.
D.
E.
Given this code for a Planet object:
What is the output?
A.
B.
C.
D.
E.
Answer is B only.
I've tested the code and I'm getting option B as answer
Idk what I was smoking but this is clearly wrong
Answer is B.
Answer is B.
Correct Answer:B
Tested. Answer is B. Source code: public class Planet { public String name; public int moons; public Planet (String name, int moons) { this.name = name; this.moons = moons; } public static void main(String[] args) { Planet[] planets = { new Planet("Mercury",0), new Planet("Venus",0), new Planet("Earth",1), new Planet("Mars",2) }; System.out.println(planets); System.out.println(planets[2].name); System.out.println(planets[2].moons); } }
Correct answer is B .name and position are directly called .
Solution is B.
Correct is Letter B, because in the first line return with hash, but in the second and third line the object is called in the position directly, now return: Planets.Planet;hash Earth 1
THE ANSWER IS B
ANSWER IS B
ANSWER IS B
String and int implement toString method => will be printed well. array not