0% found this document useful (0 votes)
12 views

Abstract

Uploaded by

Sridhar Sanapala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Abstract

Uploaded by

Sridhar Sanapala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

abstract class shape {

abstract double calculatearea();


}
class circle extends shape {
private double radius;
public circle (double radius) {
this.radius=radius; }
double calculatorarea() {
return math.pi*radius*radius; }
class rectangle extends shape {
private double base;
private double height;
public triangle(double base,double height) {
this.base=base;
this.height=height; }
double calculatorarea() {
return 0.5*base*height; }
public class abstract {
public static void main(String[] args) {
shape circle=new circle(5);
shape rectangle=new rectangle(4,6);
shape triangle=new triangle(3,4);
System.out.println("Area of circle:"+circlecalculatearea());
System.out.println("Area of rectangle:"+rectanglecalculatearea());
System.out.println("Area of triangle:"+trianglecalculatearea());
}
}

You might also like