-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShape.java
More file actions
33 lines (29 loc) · 738 Bytes
/
Shape.java
File metadata and controls
33 lines (29 loc) · 738 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
abstract class Shape{
void numberofSides(){}
public static void main(String[] args){
Shape S1 = new Rectangle();
Shape S2 = new Triangle();
Shape S3 = new Hexagon();
System.out.print("Rectangle: ");
S1.numberofSides();
System.out.print("Triangle: ");
S2.numberofSides();
System.out.print("Hexagon: ");
S3.numberofSides();
}
}
class Rectangle extends Shape{
void numberofSides(){
System.out.println("4");
}
}
class Triangle extends Shape{
void numberofSides(){
System.out.println("3");
}
}
class Hexagon extends Shape{
void numberofSides(){
System.out.println("6");
}
}