- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise_Inheritance.java
More file actions
Latest commit
33 lines (31 loc) · 814 Bytes
/
Copy pathExercise_Inheritance.java
File metadata and controls
33 lines (31 loc) · 814 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
classCircle{
publicintradius;
Circle(){
System.out.println("I am non param of circle");
}
Circle(intr){
System.out.println("I am circle parameterized constructor");
this.radius = r;
}
publicdoublearea(){
returnMath.PI*this.radius*this.radius;
}
}
classCylinder1extendsCircle{
publicintheight;
Cylinder1(intr, inth){
super(r);
System.out.println("I am cylinder1 parameterized constructor");
this.height = h;
}
publicdoublevolume(){
returnMath.PI*this.radius*this.radius*this.height;
}
}
publicclassExercise_Inheritance{
publicstaticvoidmain(String[] args) {
// Problem 1
// Circle objC = new Circle(12);
Cylinder1obj = newCylinder1(12, 4);
}
}