ExamVeda
Login
Home
Constructors and Methods
?

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

Answer & Solution
Correct Answer: Option A
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
Piyush Jain
Piyush Jain 2 years ago
Compile error