-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInheritanceCodeReusability.java
More file actions
66 lines (43 loc) · 920 Bytes
/
Copy pathInheritanceCodeReusability.java
File metadata and controls
66 lines (43 loc) · 920 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class Area {
int l;
int b;
public Area(int l, int b) {
this.l = l;
this.b = b;
}
public void display() {
System.out.println("lenght =" + this.l);
System.out.println("Breath =" + this.b);
}
}
class Rectangle extends Area {
public Rectangle(int l, int b) {
super(l, b);
}
public void RectangleArea() {
System.out.println("Area of Rectangle is =" + l * b);
}
}
class cuboid extends Area {
int h;
public cuboid(int l, int b, int h) {
super(l, b);
this.h = h;
}
public void cuboidArea() {
System.out.println("Area of cuboid is =" + l * b *h);
}
public void display() {
super.display();
System.out.println("height ="+h);
}
}
public class InheritanceCodeReusability {
public static void main(String[] args) {
Rectangle rectangle = new Rectangle(5, 20);
rectangle.RectangleArea();
cuboid c1 =new cuboid(10,20,30);
c1.cuboidArea();
c1.display();
}
}