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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:46:44+00:00 2026-05-23T04:46:44+00:00

Class A can implement multiple interfaces. What I do not understand is what happens

  • 0

Class A can implement multiple interfaces.

What I do not understand is what happens in this case:

public interface example1 {
    void checkInt(int a);
}

public interface example2 {
    void checkInt(int b);
}

public class class1 implements example1,example2 {
    void checkInt(int c){
        System.out.print(c);
    }
    this.checkint(5);
}

I tried to run it, and it gives me compilation errors. But my question is in general, can I implement two interfaces, that have a functions with the same signature?

  • 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-23T04:46:45+00:00Added an answer on May 23, 2026 at 4:46 am

    What compilations errors are you getting? Because this.checkint is in the wrong case, it should be checkInt(5) ? Also you’re reducing the scope of the method from implied public (as all interface methods are) to default (packaged protected). The checkInt method needs to be public in the implementing class.

    Both interfaces define the method, but this is fine as there is one implementation on class1. So class1 fulfils the implemented methods of each interface with its implementation of checkInt(int i). With interfaces you’re only fulfilling a contract, so there is no ambiguity about which method to call – if you work with references of type example1 or example2 it will still be the same checkInt method on class1 which gets invoked.

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

Sidebar

Related Questions

What Swing class can I use to implement something like this? Add To List
class Foo(){ public List<string> SomeCollection; } I need to implement an event which can
interfaces provide a useful abstraction capability. One can have a class Foo implement some
From code how can we know which interfaces one class implements? Example: interface IDrink
In java a class can implement Iterable which lets you use the foreach() statement
I want to implement a class which can be used by two classes of
I understand that multiple inheritance 1 is simply not supported in PHP, and while
My current non-compiling code is similar to this: public abstract class A { }
How I can implement dynamic Jtree, which shows created instances of clases? For example,
Can anyone suggest a good implementation of a generic collection class that implements the

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.