
("Operator '+' invokes toString() too: " + c6) // '+' invokes toString() too (c6) // println() calls toString() implicitly, same as above (c5.toString()) // explicit call toString() is called implicitly when an instance is passed to println() method, for example, Try calling toString() method explicitly, just like any other method: ** Return a self-descriptive string of this instance in the form of Circle */ For example, include the following toString() methods to the Circle class: If an instance is passed to the println( anInstance) method, the toString() method of that instance will be invoked implicitly. The toString() method can be called explicitly (via instanceName.toString()) just like any other method or implicitly through println(). Method toString(): Every well-designed Java class should contain a public method called toString() that returns a description of the instance (in the return type of String).Modify ALL the constructors and setters in the Circle class to use the keyword " this". "radius" refers to the method's argument


** Sets the radius to the given value */ "radius" refers to the method's parameter This.radius = radius // "this.radius" refers to the instance variable ** Constructs a Circle instance with the given radius and default color */

Exercises on Classes An Introduction to Classes and Instances by Example - The Circle Class
