top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

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

+4 votes
84 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...