Given the following code for a Planet object:
What is the output?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Given the following code for a Planet object:
What is the output?
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Option C
[Lcom.anand.scjp1.Question90;@41a4555e
com.anand.scjp1.Question90@3830f1c0
1
String name ;
int moon;
Q90(String name,int moon){
this.name=name;
this.moon=moon;
}
public static void main(String[] args) {
Q90 plants[]={
new Q90(“Mercury”,0),
new Q90(“Venus”,0),
new Q90(“Earth”,1),
new Q90(“Mars”,2)
};
System.out.println(plants);
System.out.println(plants[2]);
System.out.println(plants[2].moon);
Answer C:
Because planets and plants[2] are objects, so applying print() method on them will print their location in memory. But planet[2].moons will print the actual value of the moons in the Earth object.
it’s c
The correct answer is:C
Correct answers is : A