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