Menu
Question Index
...

What will be the output of the following program?

class Mobile {
    String str = "";
    Mobile() {
        str += "Mobile is : ";
    }
}
class Airtel extends Mobile {
    Airtel() {
        str += "Airtel";
    }
}
public class Docomo extends Mobile {
    Docomo() {
        str += "Docomo";
    }
    public static void main(String args[]) {
        Mobile d = new Docomo();
        System.out.println(d.str);
    }
}


Mobile is :
Mobile is : Docomo
Mobile is : Airtel
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