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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:17:29+00:00 2026-05-27T09:17:29+00:00

public class a implements b,c { public void g() { } public static void

  • 0
public class a implements b,c {

    public void g()
    {

    }

    public static void main(String[] args){

              a object =new a(); //this overrides for both the methods in            
                                // the interfaces b and c
          object.g();

    }

}
interface b 
{
    void g();
}
interface c
{
    void g();
}

Here I want to provide different implementations for the two interfaces . How do I do it.
In c# you can explicitly specify the overridden method is meant for which interface.Can i do that in java.If not please specify a workaround this problem with a simple example.

What I want can be stated like this… supposing the interfaces are meant for one TV remote(interface b) and a internal VCD player remote (interface c)…and when I am implementing the features of both in one remote (class a in this case)I want to provide different implementation for the TV and the VCD for the same button clicked on the remote(method g() in this case). When I override g() it gets overridden for both the interfaces.How do I explicitly mention which interface it is meant for. I want to provide different implementation(by overriding g()) for TV and VCD player.

E.X. the right direction button will work as channel change for TV but the same button will work as skip button for VCD

  • 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-27T09:17:30+00:00Added an answer on May 27, 2026 at 9:17 am

    This is the answer to the edited question:

    1. An interface simply says “this class implements method X.” It doesn’t matter how many interfaces that declare the same method you put on a class the result is still the same: “this class implements method X.”

    2. In your case, the problem is with the conceptual design. The behavior of the button is actually the same whether it’s on a TV or VCD: it fires an action when pressed. That should be the behavior of your method: find an action associated with the pressed button and execute it. See how in this case it will be the same for TV and VCD? Now, the class encapsulating the the action behavior is different. You may have a number of this classes: e.g. TVChannelChangeAction, Skip30SecAction, etc.

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

Sidebar

Related Questions

Given this code: public class Messager implements Runnable { public static void main(String[] args)
public abstract class Main implements Comparable { public static void main(String[] args) { Integer[]
In the following program. public class SerialExample { public static void main(String args[]) throws
Consider the following code : public class Main implements Vehicle, Car { public static
For example public interface X{ public void foo(X i); } public class Y implements
class Name implements Runnable { public void run() { for (int x = 1;
interface A { void hi(); } class AImpl implements A { public void hi()
@Entity public class TestClass implements Serializable{ private Integer id; private Set<String> mySet; @Id @GeneratedValue
My jpa looks like below public class TESTClass implements Serializable { ... private String
This is an example of using ThrowawayController in Spring MVC: public class DisplayCourseController implements

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.