## Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!!

# Fresher-Trainee

nisha
Fresher-Trainee
2 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners

a java program to calculate the area of different shapes using Multilevel Inheritance

March 29, 2011 at 3:52 PM

class Shape

{

```      int i=10,j=20;

void area(){
System.out.println("Find area of rectangle and square:");
}
```

}

class Rectangle extends Shape

{

```      int l=10,b=5;

void areaOfRectangle(){
area();
System.out.println("Area of Rectangle: "+l*b);
}
```

}

class Square extends Rectangle{ int side=5;

```      void areaOfSquare(){
areaOfRectangle();
System.out.println("Area of Square: "+(side*side));
}
```

}

class MultiLevelInheritanceExample{

```      public static void main(String args[]){
Square a=new Square();
a.areaOfSquare();
}
```

}

March 29, 2011 at 3:55 PM

```  class Shape{
void area(){
System.out.println("Find area of rectangle and square:");
}
}
class Rectangle extends Shape{
int l=10,b=5;
void areaOfRectangle(){
area();
System.out.println("Area of Rectangle: "+l*b);
}
}
class Square extends Rectangle{
int side=5;
void areaOfSquare(){
areaOfRectangle();
System.out.println("Area of Square: "+(side*side));
}
}
class MultiLevelInheritanceExample{
public static void main(String args[]){
Square a=new Square();
a.areaOfSquare();
}
}
```