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

  • Home
  • SEARCH
  • 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 5977935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:26:32+00:00 2026-05-22T21:26:32+00:00

1) How to solve this problem in Java? 2) What if only the return

  • 0

1) How to solve this problem in Java?

2) What if only the return types are different in the interfaces?

  • 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-22T21:26:33+00:00Added an answer on May 22, 2026 at 9:26 pm

    1) How to solve this problem in Java?

    Essentially, the different “versions” of the method in the respective interfaces all bind to the same implementation method.

    • If that’s what you want, fine.

    • If you actually want a different version of the method for each interface then you are stuck. You can’t do that in Java.


    2) What if only the return types are different in the interfaces?

    If the return types are incompatible, you cannot write a class that implements all of the interfaces. Compilation error.

    So when are return types compatible?

    • Prior to Java 5.0, the return type of an overriding or implementing method had to be the same as the return of the overridden or implemented method.

    • In Java 5.0, the language was modified to allow you to override / implement a method with a return type that is a subclass of the return type of the overridden / implemented method.

    So … if you are using Java 5.0 or later … you need to implement using a return type that is the same type or a subclass of all of the return types of all versions of the method. If there is no such type, then the class is not implementable. And obviously, this doesn’t work for primitive return types, because no subclass relationship exists between primitive types.

    (Note: in Java 5.0 +, we are talking about a subclass relationship between the declared return types … not the runtime types of the returned objects.)

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

Sidebar

Related Questions

I am trying to solve this problem. I have a series of SELECT statements
I'm trying to solve this problem : http://uva.onlinejudge.org/external/7/732.html . For the given example, they
I'm trying to solve this problem, its not a homework question, its just code
Trying to solve this problem . I would like to learn how the bootstrapper
Anyone know how to solve this problem? 03-23 13:03:20.585: WARN/googleanalytics(3430): Problem with socket or
I have an idea for how to solve this problem, but I wanted to
What's a good algorithm to solve this problem? I have three groups of people
What is the best way to solve this problem in code? The problem is
Whilst I'd love to solve this problem in python, I'm stuck in Delphi for
I've been trying to solve this problem for a number of days now but

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.