Page 637 - Computer science 868 Class 12
P. 637
2 interface shape
3 {
4 public double area();
5 }
6 class Rectangle implements shape
7 {
8 public double length,breadth;
9 Rectangle(int l, int b)
10 {
11 length=l;
12 breadth=b;
13 }
14 public double area()
15 {
16 return(length*breadth);
17 }
18 }
19
20 class Circle implements shape
21 {
22 public double radius;
23 Circle(int r)
24 {
25 radius=r;
26 }
27 public double area()
28 {
29 return(3.14*radius*radius);
30 }
31 }
Output of the preceding program is as follows:
Name of Instance: rectangl2
new Rectangle: length = 2
readth = 3
635
Internal Assessment 635

