In which of the following is toString() method defined?

Java MCQ: In which of the following is toString() method defined?

a) java.lang.Object
b) java.lang.String
c) java.lang.util
d) java.lang.Class

Answer:

a) java.lang.Object

Explanation:

The toString() method is defined in the java.lang.Object class, which is the superclass of all classes in Java. This method is often overridden to provide a string representation of an object.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top