class Box
{
double width,height,depth,vol;
Box()
{
System.out.println("Constructing Box");
width=10;
height=10;
depth=10;
}
double volume()
{
return width*height*depth;
}
}
class ConstructorOverloading
{
public static void main(String args[])
{
Box b1=new Box();
Box b2=new Box();
double vol;
vol=b1.volume();
System.out.println ("The Volume of Box:::::::"+vol);
vol=b2.volume();
System.out.println ("The Volume of Box:::::::"+vol);
}
}
Output:
.bmp)
No comments:
Post a Comment