Friday, December 6, 2013

Class in JAVA : Day 1


  Explain the General Form of a Class.   --------------------------------------------------------------------------------------------------------------------------
Write a program to find the volume of a Box. Define only three instance variables: width, height and depth. Do not use Methods.
-----------------------------------------------------------------------------------------------------------------------------
package volbox;
class Bigbox
{
   double width;
   double depth;
   double height;
}
public class Volbox
{
  public static void main(String[] args)
  {
    Bigbox lbox=new Bigbox();
    lbox.width=15;
    lbox.depth=8;
    lbox.height=20;
    double vol=lbox.width * lbox.depth * lbox.height;
    System.out.println("Volume of box is:" +vol);
  }
}