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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:16:50+00:00 2026-06-12T20:16:50+00:00

If you have one interface called A that has one method signature called print;

  • 0

If you have one interface called A that has one method signature called print; Now if you have 3 classes implementing A and you call A.print how do you know which class method gets invoked. THERE IS NO NEWING OF AN OBJECT

public interface A()
{
  public void print(){}
}
@Component
public class B implements A
{
 public void print()
 {
   system.out.print("B");
 }
}
@Component
public class c implements A
{
 public void print()
 {
   system.out.print("C");
 }
}
@Component
public class d implements A
{
 public void print()
 {
   system.out.print("d");
 }
}


public class runner()
{
    @Autowired
    private A aThing_;

    aThing_.print();
}
  • 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-12T20:16:53+00:00Added an answer on June 12, 2026 at 8:16 pm

    An interface defines an interaction contract or, in other words, defines a set of methods that every class implementing that interface should provide.

    Oracle’s answer to the question, What’s an Interface? is:

    As you’ve already learned, objects define their interaction with the
    outside world through the methods that they expose. Methods form the
    object’s interface with the outside world; the buttons on the front of
    your television set, for example, are the interface between you and
    the electrical wiring on the other side of its plastic casing. You
    press the “power” button to turn the television on and off.

    The invocation depends on the type of the object implementing the interface.

    A interface = new B();
    

    You’ll be invoking B‘s print method’s implementation for the print method defined in the A interface.

    EDIT: The point of an interface is defining the interaction with an object regardless of its actual type. That code seems to be the autoscanning of a group of components behind the same interface to show that you can define a set of different components to handle the same situation in a different way, given the context.

    AFAIK the autowire defaults to the field’s name. You can define which interface implementation you want to inject with the @Qualifier("CLASS_NAME_HERE") annotation alongside with @Autowire.

    You might want to check this.

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

Sidebar

Related Questions

I have an interface called Dictionary which has a method insert() . This interface
I have an interface that has two toolbars, one attached to the frame and
I have a class that instantiates two classes which implement interfaces. I want one
I'm creating an instance of a class called S3ObjectController (S3OC) that has one method
I'm checking an implementation of the interface IF_EX_IDOC_CREATION_CHECK which has a method IDOC_DATA_CHECK with
I have the stituation that there is an Interface I with a method m,
I have this method Verify_X which is called during databind for a listbox selected
I'd like to have one interface for all my grid related tasks.The tasks implement
Can a Objective c interface have more than one implementation? Example I could have
I have added eth0:1 with one more ip to the interface file of my

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.