Menu
Question Index
...

What will be the output of following program?

public class RectangleArea {

    public static void main(String[] args) {
        areaA rectangleArea = new rectangle();
        rectangleArea.Calculate();
        rectangleArea.Calculate();
    }
}

interface areaA {

    int l = 12;
    int b = 15;
    int h = 20;
    public int area = l * b;

    public void Calculate();
}

interface areaB extends areaA {

    public int area = l * h;

    public void Calculate2();
}

class rectangle implements areaB {

    public int area = b * h;

    public void Calculate() {
        System.out.println("Area of Rectangle here:" + area);
    }

    
    public void Calculate2() {
        System.out.println("Area of Rectangle here:" + area);
    }
}


Area of Rectangle here:180
Area of Rectangle here:300
Area of Rectangle here:300
Area of Rectangle here:300
Area of Rectangle here:300
Area of Rectangle here:240
Compilation Error or Runtime Error

Doubts

Problems

Topic: Extending Interface In Java (extends)

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App