Menu
Question Index
...

What is the output of the following program?

class Top {
    public static int area(int l) {
        return l * l;
    }
}
class Bottom extends Top {
    public static double area(int l) {
        return l * l;
    }
    public static double area(int l, int b) {
        return l * b;
    }
    public static double area(double b) {
        return 4 * b;
    }
}
public class PolyMorphism {
    public static void main(String... k) {
        System.out.println(Top.area(5) + " " + Bottom.area(2) + " " + Bottom.area(3) + "" + Bottom.area(2, 4));
    }
}


25 4 12 8
25 4.0 12.0 8.0
25 4.0 9.0 8.0
Compilation Error
Runtime Error

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App