-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverRidding.java
More file actions
44 lines (42 loc) · 826 Bytes
/
OverRidding.java
File metadata and controls
44 lines (42 loc) · 826 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
package COE;
class Shape2
{
double area(int s)
{
System.out.println("Area method of Shape Class");
return s;
}
}
class Squaree extends Shape2
{
double area(int s)
{
System.out.println("Area method of Square Class");
return s * super.area(s);
}
}
class Cube extends Squaree
{
double area(int s)
{
System.out.println("Area method of Cube Class");
return s * super.area(s);
}
}
class Circle extends Shape2
{
double area(int r)
{
System.out.println("Area method of Circle Class");
return 3.14 * r * super.area(r);
}
}
public class OverRidding {
public static void main(String[] args) {
Shape2 ob;
ob = new Cube();
System.out.println("Volumn of Cube = " + ob.area(5));
ob = new Circle();
System.out.println("Area of Circle = " + ob.area(10));
}
}