Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8959177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:23:01+00:00 2026-06-15T15:23:01+00:00

If you define a interface like below interface I1{ } The in any code

  • 0

If you define a interface like below

interface I1{

}

The in any code section you can write like

I1 i1;
i1.equals(null);

Then from where the equals method come, is the interface also extends the super class Object ?, if that true how an interface can extends a class?

Suppose let the interface extends the super class Object , then if you see why the collection interface like Set thave define the equals() and hashCode() method ?. All the class extends the Object class so if you define any abstract method in a interface which present in Object class then who implement the interface they no need to implements those method. Like in below code

interface I1{
String toString();
}

class A implements I1{

}

Here the class A no need to implements the method toString() as it’s present in Object class.
Then what is the objective of defining those method in collection interface as they can’t force there implementation class to implement those method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:23:02+00:00Added an answer on June 15, 2026 at 3:23 pm

    Then from where the equals method come, is the interface also extends the super class Object ?, if that true how an interface can extends a class?

    The Java Language Specification deals with this explicitly.

    From section 9.2:

    If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method m with signature s, return type r, and throws clause t corresponding to each public instance method m with signature s, return type r, and throws clause t declared in Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface.

    Basically, this is so that you can use equals, hashCode etc – because the way that the Java language is specified means that any concrete implementation of the interface will be a class, and that class must ultimately be a subclass of Object, so the members will definitely be present.

    To put it another way, while the interface itself doesn’t extend Object, it is known that any implementation will.

    Here the class A no need to implements the method toString() as it’s present in Object class. Then what is the objective of defining those method in collection interface as they can’t force there implementation class to implement those method.

    Usually this is just done for clarity, e.g. to document what is expected of an implementation in terms of the members declared in Object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I create a JQuery widget (code example below), and then define a public
I wanna define an interface, like public interface Visitor <ArgType, ResultType, SelfDefinedException> { public
Is it possible to define an interface (e.g. MyClass Implements MyInterface) whose method/property definitions
I'm trying to define a method in my vb.net interface that will only accept
why is it recommended to define service contract as an interface. Any specific advantages
I am trying to define a WCF contract that returns an interface, something like
Eclipse allows us to define a class as: interface MyInterface { void methodA(); int
In one class, I define an NSMutableArray with getters and setters: @interface ArrayClass :
I have the interface defined as below and is implemented by a single class
I am trying to define interface types in C++ using abstract classes and implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.