Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $4.99 payment

Question: 1 / 515

What is the output of calling the 'toString()' method on an Object, which is not overridden?

The class name and the object's hash code

Calling the 'toString()' method on an Object that is not overridden will result in the class name and the object's hash code being outputted. This is because the 'toString()' method outputs a textual representation of an object, and if not overridden, it will default to the implementation provided by the Object class. This implementation includes the class name and the hash code, making option A the correct answer. Options B and C are incorrect because they do not pertain to the 'toString()' method or the default implementation for an Object. Option D is incorrect because the 'toString()' method does not return a blank string unless overridden to do so.

The memory address of the object

The values of the object's fields

A blank string

Next

Report this question