Menu
Question Index
...

What will be the output of the following program?

class Super {
    public Integer getLength() {
        return new Integer(4);
    }
}
public class Sub extends Super {
    public Long getLength()    {
        return new Long(5);
    }
    public static void main(String[] args) {
        Super sooper = new Super();
        Sub sub = new Sub();
        System.out.println(sooper.getLength().toString() + ", " + sub.getLength().toString());
    }
}


4, 4
4, 5
5, 4
Compilation Error
Runtime Error

Doubts

Problems

Topic: Method Overriding 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