81.
What will be the output of the following Java program?
class box 
{
    int width;
    int height;
    int length;
    int volume;
    void volume() 
    {
         volume = width*height*length;
    } 
}    
class Output 
{ 
    public static void main(String args[])
    {
        box obj = new box();
        obj.height = 1;
        obj.length = 5;
        obj.width = 5;
        obj.volume();
        System.out.println(obj.volume);        
    } 
}

86.
What will be the output of the following Java code?
class box 
{
    int width;
    int height;
    int length;
    int volume;
    box() 
    {
        width = 5;
        height = 5;
        length = 6;
    }
    void volume() 
    {
         volume = width*height*length;
    } 
}    
class constructor_output 
{
    public static void main(String args[])
    {
        box obj = new box();
        obj.volume();
        System.out.println(obj.volume);
    }
}

Read More Section(Constructors and Methods)

Each Section contains maximum 100 MCQs question on Constructors and Methods. To get more questions visit other sections.