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, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment