Machine-translated by Google. Questions are authored in English.
Top

Discussion

The format of the string Object.toString returns by default - which of the following is true?

  • A.The simple class name followed by the object's identity hash code in decimal.
  • B.The fully qualified class name only, with no identifying suffix.
  • C.The class name, an at sign, and the hash code in unsigned hexadecimal.
  • D.The class name, a colon, and the object's field values separated by commas.

Answer: C

The javadoc defines it exactly as getClass().getName() + '@' + Integer.toHexString(hashCode()), giving output such as java.lang.Object@1b6d3586. The number is a hexadecimal hash code, not an address and not a decimal, and it is the usual sign that a class has not overridden toString.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.