-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP1.java
More file actions
38 lines (30 loc) · 723 Bytes
/
P1.java
File metadata and controls
38 lines (30 loc) · 723 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
class Circle{
public int radius;
Circle(){
System.out.println("I am not parametrized Constructor");
}
Circle(int r){
System.out.println("I am the Circle Parameterized Constructor");
this.radius=r;
}
public double area() {
return Math.PI*this.radius*this.radius;
}
}
class Cylinder extends Circle {
public int height;
Cylinder(int r,int h){
super(r);
System.out.println("I am Cylinder Parametrized Constructor");
this.height=h;
}
public double Volume() {
return Math.PI*this.radius*this.radius*this.height;
}
}
public class P1 {
public static void main(String[] args) {
//Circle obj=new Circle(12);
Cylinder r=new Cylinder(12,16);
}
}