-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathInnDemo.java
More file actions
38 lines (37 loc) · 731 Bytes
/
InnDemo.java
File metadata and controls
38 lines (37 loc) · 731 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
/*Inheritance*/
class Box{
private int length,width;
public void getData(int length,int width){
this.length=length;
this.width=width;
}
public void showData(){
System.out.println("Lenghth is\t"+length+"\t Width is\t"+width);
}
public int getCal(){
return length*width;
}
}
class ChildBox extends Box{
private int height,volume;
public void init(int a1,int a2,int a3){
getData(a1,a2);
height=a3;
}
public int calVolume(){
volume=getCal()*height;
return volume;
}
public void Display(){
showData();
System.out.println("Height is \t"+height+"\tVolume is\t"+volume);
}
}
class InnDemo{
public static void main(String ar[]){
ChildBox c1=new ChildBox();
c1.init(3,4,5);
c1.calVolume();
c1.Display();
}
}