File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ //the abstract class can not become a object it is features of it.
3
+ abstract class shape
4
+ {
5
+ void display()
6
+ {
7
+
8
+ }
9
+ }
10
+
11
+ class cir extends shape{
12
+ void display()
13
+ {
14
+ System.out.println("shape is circle is right now");
15
+ }
16
+ }
17
+
18
+ class rectan extends shape{
19
+ void display()
20
+ {
21
+ System.out.println("the shape is rectangle");
22
+ }
23
+ }
24
+ public class abstaract {
25
+
26
+ public static void main(String[] args)
27
+ {
28
+
29
+ ///abstract class object
30
+ //error like this:'shape' is abstract; cannot be instantiated
31
+ //shape s=new shape();
32
+ // s.display();
33
+
34
+
35
+ //instance is cir
36
+ shape s =new cir();
37
+ s.display();
38
+
39
+ //instance is rectan
40
+
41
+ s=new rectan();
42
+ s.display();
43
+ }
44
+ }
You can’t perform that action at this time.
0 commit comments