Task: Write a Java program to create a new Box class in Java. Use three instance variables width, height and depth of type double. Write down two constructors. Default ( no-arg )constructor will intialize the Box class objects with 0.0 value for all instance variables. A parameterized constructor will be used to intialize the object with different values.
Write down a method called volume() that will calculate and show the volume of the box.
Write down a main class to use this Box class. Create some objects of Box class and show the functionality.
Java Source code for designing and using a new class Box
Output of the Java program to create new class Box
2,914 total views, 11 views today