36.7k views
5 votes
In order to "print" the data in an object, the class should override the _____ method.

String
toString
StringValue
Value

User Hans One
by
4.8k points

1 Answer

3 votes

Answer:

toString is right Answer

Step-by-step explanation:

If you want to represent any object as a string, toString() method comes into existence.

The toString() method returns the string representation of the object.

If you print any object, java compiler internally invokes the toString() method on the object. So overriding the toString() method, returns the desired output, it can be the state of an object etc. depends on your implementation.

User KoleS
by
5.3k points