top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Java: Why toString() method declaration is in charSequence interface?

+4 votes
234 views
Java: Why toString() method declaration is in charSequence interface?
posted Oct 20, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

When an interface has no direct SuperInterface, it will create abstract public method for all those public methods present in the Object class.

So that how u were able to call the toString() method on the interface reference.

Object has a toString() method, so everything (except primitive types) has a toString() method. Java will treat anything, even an empty interface, as having all the methods of Object, because it always does.

Any Object has a toString() method. Anything that would implement an interface will implicitly extend Object, so will also have a toString() method.

answer Oct 21, 2014 by Amit Kumar Pandey
Similar Questions
...