Try To Predict Output--2


Test Your Java Fundamentals By Predict Its Output.......
Comment If you Like It........ 




class Scratch {
    public static void main( String[] args) {
        Parent p1 = new Parent();
        Parent p2 = new Parent();
        Child c1 = new Child();
        Child c2 = new Child();

        Parent.x = 1;
        Child.x = 2;

        p1.x = 3;
        p2.x = 4;

        p1.y = 5;
        p2.y = 6;

        Child.z = 7;

        c1.x = 8;
        c2.x = 9;

        c1.y = 10;
        c2.y = 11;

        c1.z = 12;
        c2.z = 13;

        c1.w = 14;
        c2.w = 15;

        System.out.println("Parent.x: " + Parent.x);
        System.out.println("Child.x: " + Child.x);
        System.out.println("p1.x: " + p1.x);
        System.out.println("p2.x: " + p2.x);
        System.out.println("p1.y: " + p1.y);
        System.out.println("p2.y: " + p2.y);
        System.out.println("Child.z: " + Child.z);
        System.out.println("c1.x: " + c1.x);
        System.out.println("c2.x: " + c2.x);
        System.out.println("c1.y: " + c1.y);
        System.out.println("c2.y: " + c2.y);
        System.out.println("c1.z: " + c1.z);
        System.out.println("c2.z: " + c2.z);
        System.out.println("c1.w: " + c1.w);
        System.out.println("c2.w: " + c2.w);
    }


}

class Parent {
    static int x;
    int y;
}

class Child extends Parent{
    static int z;
    int w;
}

No comments:

Post a Comment