adplus-dvertising
frame-decoration

Question

What is the output of this program?
    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();
        } 
    }

a.

150

b.

200

c.

Run time error

d.

Compilation error

Posted under Java Programming

Answer: (a).150

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?