-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8.java
More file actions
46 lines (39 loc) · 923 Bytes
/
Copy path8.java
File metadata and controls
46 lines (39 loc) · 923 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
class Shape {
public void print() {
System.out.println("This is a shape");
}
}
class Polygon extends Shape {
public void print() {
System.out.println("Polygon is a shape");
}
}
class Rectangle extends Polygon {
public void print() {
System.out.println("Rectangle is a polygon");
}
}
class Triangle extends Polygon {
public void print() {
System.out.println("Triangle is a polygon");
}
}
class Square extends Rectangle {
public void print() {
System.out.println("Square is a rectangle");
}
}
public class Main {
public static void main(String[] args) {
Shape s = new Shape();
Polygon p = new Polygon();
Rectangle r = new Rectangle();
Triangle t = new Triangle();
Square sq = new Square();
s.print();
p.print();
r.print();
t.print();
sq.print();
}
}