- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabstrct.java
More file actions
Latest commit
60 lines (53 loc) · 836 Bytes
/
Copy pathabstrct.java
File metadata and controls
60 lines (53 loc) · 836 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
46
47
48
49
50
51
52
53
54
55
56
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author g1.test1
*/
abstractclassl
{
doubledim1,dim2;
l(intx,inty)
{
dim1=x;
dim2=y;
}
abstractdoublearea();
}
classrecextendsl
{
rec(intx,inty)
{
super(x,y);
}
doublearea()
{
return (dim1*dim2);
}
}
classtrinextendsl
{
trin (intx,inty)
{
super(x,y);
}
doublearea()
{
return (dim1/2*dim2);
}
}
publicclassabstrct {
publicstaticvoidmain(Stringargs[])
{
// a obj=new a(); cannot be made as abstract
recobj1=newrec(10,20);
trinobj2=newtrin(20,30);
lref;
ref=obj1;
ref=obj2;
System.out.println(obj1.area());
System.out.println(obj2.area());
}
}