-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRectangle.java
More file actions
47 lines (38 loc) · 861 Bytes
/
Rectangle.java
File metadata and controls
47 lines (38 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Shape extends Display{
int length,height;
Shape(){
System.out.println("Shape");
}
Shape(int l,int h){
super(l,h);
length = l;
height = h;
}
public int area(){
return length*height;
}
}
class Display {
Display(){
System.out.println("Display");
}
Display(int l, int h){
//do nothing
}
public void show(int area){
System.out.println("Area of the rectangle is :" + area);
}
}
public class Rectangle extends Shape {
Rectangle(){
System.out.println("Rectangle");
}
Rectangle(int l,int h){
super(l,h);
}
public static void main(String[] args){
new Rectangle();
Rectangle rect = new Rectangle(2,2);
rect.show(rect.area());
}
}