-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExample5.java
More file actions
44 lines (37 loc) · 780 Bytes
/
Copy pathExample5.java
File metadata and controls
44 lines (37 loc) · 780 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
//super keyword and uses
class Box
{
private int l,b,h; //instance member variable
public void setDimension(int l,int b,int h) //local variables
{
this.l = l;
this.b = b;
this.h= h;
}
public void showDimension()
{
System.out.println("Length ="+l+" Width = "+b+" hieght = "+h);
}
}
//subclass
class subbox extends Box //inherited class
{
public void showDimension()
{
System.out.println("subclass showDimension");
super.showDimension(); //super denotes Box class function
}
}
public class Example5
{
public static void main(String []args)
{
Box b1 = new Box();
b1.setDimension(10,6,4);
b1.showDimension();
//create object of class box
subbox box1 = new subbox();
box1.setDimension(20,15,8);
box1.showDimension();
}
}