Menu
Question Index
...

What will be the output of the following program?

public class Example {
    public static void main(String args[]) {
        A a = new A(10);
        B b = new B(20, 30);
        System.out.println(a.i);
        System.out.println(b.i);
    }
}
class A {
    int i;
    A(int i) {
        this.i = i;
    }
}
class B extends A {
    int j;
    B(int i, int j) {
        this.j = j;
        super(i);
    }
}


10
20
30
10
20
40
10
20
10
Compilation Error
Runtime Error

Doubts

Problems

Topic: Super Keyword In Java To Call Super Class Constructor

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App