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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:14:46+00:00 2026-06-09T06:14:46+00:00

Consider the example below. Why is it so that I’m not allowed to use

  • 0

Consider the example below.

Why is it so that I’m not allowed to use BImpl as a parameter type of method doSomething3? When I say “not allowed to”, I mean that Eclipse is complaining that the doSomething3-method from the interface AInf is not implemented.

interface AInf
{
    AInf doSomething();
    BInf doSomething2();
    void doSomething3(BInf param);
}


interface BInf
{

}

class AImpl implements AInf
{

    @Override
    public AImpl doSomething() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public BImpl doSomething2() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void doSomething3(BImpl param) // This method is not overriding the doSomething3(BInf param) from the AInf
    {
        // TODO Auto-generated method stub
    }
}

class BImpl implements BInf
{

}
  • 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-09T06:14:48+00:00Added an answer on June 9, 2026 at 6:14 am

    Because doSomething3(BImpl param) doesn’t implement doSomething3(BInf param).

    BInf can have many implementations, and the method should work for all of them, not just one.

    Always bear in mind that extending a class or implementing an interface defines an is a relationship. All the rules of widening/narrowing are logical consequences of this.

    It’s easier if you imagine it with a specific example: money. Coins are money and notes are money too.

    If you go to a shop which decided to restrict the change they give you from your purchase to coins, it may be annoying but it’s legal. It’s fine because it doesn’t break the contract, they are always returning money.

    But when you’re in a shop where they’re supposed to accept money and they won’t accept your coins, that’s not okay.

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

Sidebar

Related Questions

Consider the simple example below of implementing a method in an Enum. One problem
Consider the example plot below. I'd like to make the little boxes around each
Let's consider the below example. There, I have: target MAIN calls target t and
Consider this example: zh_Hant_HK format = yy'年'M'月'd'日' ah:mm Not sure if you can see
Consider the example below: #include <iostream> using namespace std; class base { public: virtual
The question is pretty straight forward. For clarity, consider the example below: // Note
Consider the code below (which has been simplified). I have a service class that
I have a multi-dimensional array similar to the example below that I want to
Consider I have a table, like below, that I am trying to populate with
Consider the minimal example below. It works perfectly until I uncomment the following lines:

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.