JAVA 16/11

Sample7.java

class Room
{
    int length;
    int width;
    
    Room(int L, int W)
    { 
        length = L;
        width = W;
    }
    
    int area()
    {
        return (length * width);
    }
}

class BedRoom extends Room
{
    int height;
    
    BedRoom(int L, int W, int H)
    {
        super(L, W);
        height = H;
    }
    
    int volume()
    {
        return (length * width * height);
    }
}

class Sample7
{
    public static void main(String args[])
    { 
        BedRoom obj1 = new BedRoom(2, 3, 4);

        System.out.println("Volume: " + obj1.volume());
        System.out.println("Area: " + obj1.area());
    }
}