LogiQuest
Back to Objects and Classes
1

What is the output of the following program?

class Main {
    int x;
    Main(int x) { this.x = x; }
    public static void main(String[] args) {
        Main a = new Main(5);
        Main b = a;
        b.x = 9;
        System.out.println(a.x);
    }
}
Medium

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.