Home » JAVA Programming » Object & Classes » Question
  1. What is the output of this program?

    class box_Shape
    {
    int width;
    int height;
    int length;
    }
    public class mainclass
    {
    public static void main(String args[])
    {
    box_Shape obj = new box_Shape();
    System.out.println(obj);
    }
    }
    1. Compiletime error
    2. Runtime error
    3. Garbage value
    4. box_Shape@2a139a55
    5. None of these
Correct Option: D

When we print object internally toString() will be called to return string into this format classname@hashcode in hexadecimal form.
Output: box_Shape@2a139a55



Your comments will be displayed only after manual approval.