Skip to content

Commit f121c08

Browse files
abstract_class
1 parent bf93c7c commit f121c08

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

abstract _class_java

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
}

0 commit comments

Comments
 (0)