Menu
Question Index
...

What will be the output of the following program?

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


a.i = 10
a.i = 0
a.i = null
Compilation Error
Runtime Error it throws NullPointerException

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