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 6886677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:47:22+00:00 2026-05-27T05:47:22+00:00

Just for the curiosity I tried this: public interface test1 { public Object method1(String

  • 0

Just for the curiosity I tried this:

public interface test1 {
    public Object method1(String str);
}

public interface test2 {
    public Object method1(String str);
}

public class Test implements test1, test2 {    
    public static void main(String... args) {

    }

    public Object method1(String str) {
        return new Object();
    }
}

I was expecting some sort of error on line public class Test implements test1, test2 { from Eclipse, but there was none.

  1. Why there is no compile time error since there is a collision of
    method names?
  2. How many methods are inherited in class Test?
  3. If the answer of the above question is 2, then exactly which method
    have we implemented?
  4. And at runtime, how come the properly implemented method is
    selected? and not the other one?
  5. And finally, is there a way to implement both? (I am almost sure that the answer is NO)

I know that from the design point of view, this may not happen in the real world situations, but as I have mentioned at the beginning, it just came to my mind and I tried it out.

Any clarification/reference is greatly appreciated.

  • 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-05-27T05:47:22+00:00Added an answer on May 27, 2026 at 5:47 am

    There is no collision. Both interfaces require a method called method1, and both are satisfied by the method1 in your example class. When you implement an interface, you are not inheriting any methods at all; you are only promising to implement the methods yourself.

    For the answer to your final question, see this existing SO question:

    Java – Method name collision in interface implementation

    There is a proposal for Java 8 to allow interfaces to specify a default implementation, called Virtual Extension Methods. If that makes it into the language, it will be possible for two interfaces to specify different default implementations for the same method signature. If those interfaces are then implemented by one class then it will have to provide its own implementation (i.e. it will be equivalent to neither interface specifying a default) – see 3.3. Conflicting defaults.

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

Sidebar

Related Questions

Just out of curiosity I tried overriding a abstract method in base class, and
This is just a curiosity question. I know that Spring can be used in
Just a general curiosity question. Why is this namespace System.Collections.Generic added by default in
Just out of curiosity, asking this Like the expression one below a = (condition)
This is mostly just out of curiosity, and is potentially a silly question. :)
This is just to satisfy my own curiosity. Is there an implementation of this:
This is just for curiosity. Exposé has two functions, among others, that rearrange windows
Just for curiosity/convenience: C# provides two cool conditional expression features I know of: string
Just a curiosity question! This seems to suggest that member function pointers are in
This is just curiosity on my part, but what is more efficient, recursion or

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.