Menu
Question Index
...

What will be the output of the following program?

class Copy {
    public static void main(String arg[]) {
        Test a = new Test();
        a.i = 10;
        Test b = a;
        b.i = 5;
        System.out.println("a.i = " + a.i);
        System.out.println("b.i = " + b.i);
    }
}
class Test {
    int i;
}


a.i = 10
b.i = 5
a.i = 10
b.i = 10
a.i = 5
b.i = 5
Compilation Error or Runtime Error

Doubts

Problems

Topic: Member Variable In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App