Write a program to show concept of Class in Java
class box {
double width;
double height;
double depth;
}
class boxdemo {
public static void main (String arg[]) {
box mybox1 = new box();
double vol;
//assign values to mybox1's instance variables
mybox1.width=10;
mybox1.height=20;
mybox1.depth=15;
vol=mybox1.width * mybox1.height * mybox1.depth;
System.out.print("Volume : "+vol);
}
}
Post a Comment