-
Notifications
You must be signed in to change notification settings - Fork 2
/
abstractclass.java
53 lines (52 loc) · 936 Bytes
/
abstractclass.java
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
abstract class shapes
{
abstract int numberofsides();
}
class rectangle extends shapes
{
private static int sides=4;
int numberofsides()
{
return sides;
}
void display()
{
System.out.println("Rectangle:"+sides);
}
}
class triangle extends shapes
{
private static int sides=3;
int numberofsides()
{
return sides;
}
void display()
{
System.out.println("Triangle:"+sides);
}
}
class hexagon extends shapes
{
private static int sides=6;
int numberofsides()
{
return sides;
}
void display()
{
System.out.println("Hexagon:"+sides);
}
}
public class shape
{
public static void main(String args[])
{
rectangle rect=new rectangle();
triangle tri=new triangle();
hexagon hex=new hexagon();
rect.display();
tri.display();
hex.display();
}
}