Menu
Question Index
...

What will be the output of the following program?

public class Display1 extends Display2 {
    int number = Math.round(7.4f);
    public static void main(String args[]) {
        Display2 base = new Display1();
        base.print();
    }
    void print() {    System.out.print(number + " ");    }
}
class Display2 {
    Display2() {    print();    }
    void print() {    System.out.print("Base1" + " ");    }
}


Base1 7
Base1 Base1
7 7
0 7
Compilation Error or 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