Menu
Topics Index
...
`

Abstract Classes956


If you need explanation Read this topic

If you need Answer Take test on this topic

Abstract Classes956
What will be the output of the following program?
class CalculateAreas
{
    public static void main(String arg[])
    {
        Square sq = new Square(5.25);
        System.out.println("Area of Square is " + sq.getArea());
    }
}

abstract class Shape
{
    abstract double getArea();
}

class Square extends Shape
{
    double side;

    double getArea()
    {
        return side * side;
    }
}

A. Area of Square is 27.5625
B. Area of Square is 0
C. Compilation Error
D. Runtime Error
Topic: Abstract Method In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans isi C,there is no constructor with parameter(double).

Posted by Raviteja Daggupati    2014-02-12 08:14:12


ans c:because at least one public class is required in main file

Posted by Manasa Jyothi Sree    2014-02-12 08:19:17


Congratulations Raviteja Daggupati. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-02-13 04:11:46


© meritcampus 2019

All Rights Reserved.

Open In App