Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com

Output in java

Easy
0/10

Problem statement

What is the output of this program?

class A {
    int i;
    void display() {
        System.out.println(i);
    }
}    
class B extends A {
    int j;
    void display() {
        System.out.println(j);
    }
}    
class inheritance_demo {
    public static void main(String args[])
    {
        B obj = new B();
        obj.i=1;
        obj.j=2;   
        obj.display();     
    }
}
Options: One or more answers may be correct