Menu
Question Index
...

What will be the output of the following program?

public class Family {
    public static void main(String[] args) {
        GS gs = new GS();
        gs.a = 10;
        gs.b = 20;
        gs.c = 30;
        System.out.println(gs.a + ", " + gs.b + ", " + gs.c + ", " + gs.d);
    }
}
class F {
    int a;
}
class M extends F {
    int b;
}
class S extends M {
    int c;
}
class GS extends S {
    int d = 40;
}


10, 20, 30, 0
10, 20, 30, 40
Compilation Error
Runtime Error

Doubts

Problems

Topic: Multilevel Inheritance In Java With Example Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App