Examveda

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

A. 0

B. 1

C. 30

D. error

Answer: Option D


This Question Belongs to Java Program >> Constructors And Methods

Join The Discussion

Related Questions on Constructors and Methods

What is a constructor in Java?

A. A special method to create instances of classes

B. A method used for mathematical calculations

C. A method to perform string manipulations

D. An exception handling mechanism