Skip to content
Quiz · Classes and objects · lesson 2 of 10

Quiz — two variables, one object

What does the program print?

JAVA
public class Main {
    public static void main(String[] args) {
        Point p = new Point();
        p.x = 1;
        Point q = p;
        q.x = 7;
        q = new Point();
        q.x = 9;
        System.out.println(p.x);
    }
}
class Point { int x; }