Menu
Question Index
...

What will be the output of the following program?

public class IAm {
    public static void main(String arg[]) {
        float input = 24.8888888888888889f;
        School ref = null;
        if (input < 10) {
            ref = new School();
        } else if (input > 30) {
            ref = new College();
        } else if (input == 24.88889) {
            ref = new Office();
        }
        ref.display();
    }
}
class School {
    void display() {
        System.out.println("I am studying 10th class.");
    }
}
class College extends School {
    void display() {
        System.out.println("I am studying B.Tech.");
    }
}
class Office extends School {
    void display() {
        System.out.println("I am working in S/W company.");
    }
}


I am studying 10th class.
I am studying B.Tech.
I am working in S/W company.
Compilation Error
Runtime Error

Doubts

Problems

Topic: Run Time Polymorphism In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App