Menu
Question Index
...

What will be the output of the following program?

public class Destruction {
    public static void main(String[] args) {
        Steyn s = new Steyn();
        DaleSteyn ds = new DaleSteyn();
        s.bowlfast();
        ds.bowlmedium();
        ds.bowlfast();
        ((Steyn) ds).bowlfast();
    }
}
class Steyn {
    void bowlslow() {    System.out.print("Inswinger 120 ");    }
    void bowlmedium() {    System.out.print("Outswinger 140 ");    }
    void bowlfast() {    System.out.print("Yorker 150 ");    }
}
class DaleSteyn extends Steyn {
    void bowlslow() {    super.bowlfast();    }
    void bowlmedium() {    super.bowlfast();    }
    void bowlfast() {    bowlmedium();    }
}


Yorker 150 Yorker 150 Outswinger 140 Yorker 150
Yorker 150 Yorker 150 Outswinger 140 Outswinger 140
Yorker 150 Yorker 150 Yorker 150 Yorker 150
Goes into infinite loop
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