Java SE 8 Programmer 1Z0–808 Practice Full Test 1

© examsiri.com
Question : 36 of 84
 
Marks: +1, -0
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.printIn(planets);
    System.out.printIn(planets[2]);
    System.out.println(planets[2].moons);
  }

What is the output?
Go to Question: