Java Program For Finding Volume With Construction Box

class Box
{
 double width;
 double height;
 double depth;
        
        Box()
 {
          System.out.println("constructing box"); 
         width=10;
         height=20;
         depth=15;
        }

 double volume()
 {
         return width*height*depth;
 
 }
        
}

class BoxDemoCon2
{
public static void main(String args[])
{
Box mybox1= new Box();
Box mybox2= new Box();
double vol;
vol=mybox1.volume();
System.out.print(" Volume is " + vol); 

vol=mybox2.volume();
 System.out.print(" Volume is " + vol); 
 
}
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.

No comments:

Post a Comment