Since class Demo
implicitly extends
class Object
, it inherits method toString
. And since that's not an abstract
method, class Demo
is not forced to provide an implementation, although you're able to directly invoke toString
on an instance of Demo
. For more information, please see Lesson: Interfaces and Inheritance.
As stated in the Object API,
Class Object
is the root of the class hierarchy. Every class has
Object
as a superclass. All objects, including arrays, implement the
methods of this class.
Also, note that the toString
method is not part of the interface definition, but rather the Object
class definition.