Menu
Question Index
...

What will be the output of the following program?

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


Docomo
Mobile is : Airtel
Mobile is : Docomo
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Creating Static Methods In Java Using Static Keyword

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App