Write a program to show use and advantages of Constructor in Java
class Box {
double l;
double b;
double h;
Box() {
l=2.3;
b=3.4;
h=4.5;
}
void show() {
System.out.print("the volume of the box is : " +(l*b*h));
}
}
class volume {
public static void main(String args[]) {
Box o=new Box();
o.show();
}
}
Post a Comment