[b]Two Interfaces with same method signature[/b]

Hi,
I am having 2 interfaces which does have same method signature and
return type. In such case a class that implements these intefaces and overide
the method . In such case which method will execute . The method of class A or
class B otherwise one will be ignored by the JVM and other will be executed or
not???
For eg,
interface A
public void getData();
interface B
public void getData();
class InterfaceTest implements A,B
public void getData()
System.out.println("Inside the getData()");
public static void main(String args[])
InterfaceTest interTest=new InterfaceTest();
interTest.getData(); // Which method will execute Class A or B.
Please do provide an answer for this. I will be waiting for ur reply...
Thanks,
M.Ananthu

there is but one implementation, so why bother ?
what's more, you're talking about "class A" and "class B" when you defined A and B as interfaces
seems blurry in your mind...

Similar Messages

  • Class implementing two interfaces with same methods

    interface Foo {
    public void execute();
    interface Bar {
    public void execute();
    class Dam implements Foo, Bar {
    public void execute() {
    //Which interface's execute method is being called here?
    How do I make the Damn class have different implemenations for the execute method of the Foo and the Bar interfaces?

    hi,
    //Which interface's execute method is being calledinterfaces' method are neither called to be executed by the JVM because they're not concrete implementation but only signature declaration.
    How do I make the Damn class have different
    implemenations for the execute method of the Foo and
    the Bar interfaces?this can't be done if the signatures are the same, but if they're not, for instance
    public void execute( int i )
    public void execute( String s )
    then you can have two implementation...anyway, what's the point if the signature are the same ? if you really want them to do different things why wouldn't you name them differently ?
    raphaele

  • Interfaces with same method names

    Hello!
    A theoretical question:
    There's a class, which implements 2 interfaces. Each interface has a method 'modszer'. Here's the code:
    InterfaceA.java:
    interface InterfaceA {
      void modszer();
    InterfaceB.java:
    interface InterfaceB {
      void modszer();
    Osztaly.java:
    public class Osztaly implements InterfaceA, InterfaceB {
      public void modszer() {
        System.out.println("So, which?");
    FoOsztaly.java:
    public class FoOsztaly {
      public static void main(String[] args) {
        Osztaly o = new Osztaly();
        o.modszer();
        InterfaceA ia = o;
        ia.modszer();
        InterfaceB ib = o;
        ib.modszer();
    Sorry for the hungarian class names.
    So how can I implement both 'modszer' methods, for example the method belongs to InterfaceA should return 'A' and the method if InterfaceB should return 'B'?
    Thank you!

    Only if they have different return types.There can be a problem with inheriting a method from
    two different interfaces even if they have exactly the
    same signature.
    Consider the following interfaces and class:
    interface Rectangle {
    /** Display the rectangle on the screen */
    void draw();
    interface Card {
    /** Remove the card from the deck */
    void draw();
    class GraphicCard implements Rectangle, Card {
    /** What should this do!?!? */
    public void draw();
    }In this case, the draw() method in GraphicCard should
    satisify two different contracts -- which one should
    it satisfy? This is a real problem with multiple
    inheritance of interface. It isn't as much of a
    problem as multiple inheritance of implementation (as
    in C++), but it still can be a problem when interface
    methods have poorly chosen names.my solution to ur problem is
    interface Rectangle{
    void draw();
    interface card {
    void draw();
    class Test implements Rectangle, Card
    static String choice=null;
    void Test(String str)
    choice=string;
    void draw()
    if(choice.equals("Rectangle"))
    //do
    if(choice.equals("Card"))
    //do
    give this class to the user or application
    if he wants to use rectangle or card
    class User
    Recatangle rec=(Rectangle)new Test("Rectangle");
    rec.draw();
    Card card=(Card) new Card("Card");
    card.draw();
    get back to me if iam wrong
    regards
    kamal

  • Populate two table with same method

    Hi
    I have two tables in my iview. Both have same column structure but populates data from two different folders.
    The context nodes are also similair only difference being change in the node name.
    I was thinking about one single method which can be used to fill both the tables.
    But I  am having difficulty in passing the arguments to this method.
    Can any1 guide me...
    Regards
    Bobu

    Hi Bobu,
    You can create a method with the two parameters
    1. IWDNode
    2.IWDNodeElement
    You need to call these methods when you want to fill the table. While calling this method you need to send the above two parameters with different Node and Node element references.. We can take referecne of different node with A and B as the node names as
    IWDNode  refA = wdContect.NodeA();
    IWDNode  refB = wdContect.NodeB();
    IWDNodeElemtn refelemA = refA.createElement();
    IWDNodeElemtn refelemB = refB.createElement();
    Thanks,
    Raju Bonagiri

  • Two Interface with same IDOC sperated by Document Type

    Hi All,
    I have Two interface which is for RFQ and Purchase order, bother uses same IDOC orders05, i need to indentify which one for which interface using Document type for purchase NB and and AN for RFQ , please help me to slove this isssue , hope we muct use Context object for this , but i dont know how to use it , please help me
    thanking you
    Sridhar

    Hi,
    Can you explain a bit about your scenario, coz I think it can be handle in other way without using context objects..
    But if you want to use the context object, then you can add it in Message Interace ---> Context Objects, and in ID while doing RD you can find it under Condition Editor ---> take F4 help and then select context objects.
    Regards,
    Sarvesh

  • Two Switches with same MAC+Priority running STP

    Hi
    what will happen if two switch with same MAC-ADDRESS and same STP priority will run STP , how will elect to the root bridge ???? how the STP process will handle this situation?
    thanx

    Well, first off, no two switches (or switchports) will have the same MAC (if they do, you're buying switches from the wrong, very bad place).
    Every port of the switch will have (at least) one MAC of it's own.
    Given the same priority for all switches/bridges on the LAN, the lowest switch/bridge MAC on the LAN will win as the root.
    VLANS take on the MAC of the administrative interface ("CPU"): i.e., xxxx.xxxx.5000, the first port (i.e., fa0/1) is xxxx.xxxx.5001, the second (fa0/2) is xxx.xxxx.5002, and so on
    If you do a "show interface", the MAC / bia is displayed in the second line.
    Good Luck
    Scott

  • When to use abstract classes instead of interfaces with extension methods in C#?

    "Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived classes when needed. In C#, however,
    this differentiating factor has been reduced by the recent introduction of extension methods, which enable implementations to be provided for interface methods. Another differentiating factor is that a class can inherit only one abstract class (i.e., there
    is no multiple inheritance), but it can implement multiple interfaces. This makes interfaces less restrictive and more flexible. So, in C#, when should we use abstract classes
    instead of interfaces with extension methods?
    A notable example of the interface + extension method model is LINQ, where query functionality is provided for any type that implements IEnumerable via
    a multitude of extension methods.

    Hi
    Well I believe Interfaces have more uses in software design. You could decouple your component implementing against interfaces so that
    you have more flexibility on changing your code with less risk. Like Inversion of Control patterns where you can use interfaces and then when you decide you can change the concrete implementation that you want to use. Or other uses for interfaces is you could
    use Interceptors using interfaces (Unity
    Interceptor) to do different things where not all of these is feasible or at least as straightforward using abstract classes.
    Regards
    Aram

  • Struts- two actions with same path in struts config

    hai
    I am having html:select tag with two options (View And Download) in a form.My form signature is like <html:form action="select">.I mapped two options(View,Download) with same action path.When i click view it doesn't forwards(remains idle) and no error is shown.But i click download it forwards to the appropriate page.If iam having two tags with same action path the second is only working.This problem doesn't comes when iam having one tag alone.
    My code is here:
    -----------Select.jsp----------------
    <html:form action="Select">
    <html:select property="id">
    <html:option value="view">View</html:option>
    <html:option value="download">Download</html:option>
    </html:select>
    </html:form>
    ----------------Struts-config.xml------------
    <form-beans>
    <form-bean name="viewForm" type="ViewForm"/>
    <form-bean name="download" type="DownloadForm"/>
    </form-beans>
    <action-mappings>
    <action path="/Select"
    name="viewForm"
    type="ViewAction"
    input="/Select.jsp">
    <forward name="success" path="/Success.jsp"/>
    </action>
    <action path="/Select"
    name="downloadForm"
    type="DownloadAction"
    input="/Select.jsp">
    <forward name="success" path="/Welcome.jsp"/>
    </action>
    </action-mappings>
    Can i have action tag with same paths like this.If not please provide me a solution

    I have created two success pages.
    I have created two findForward in my ActionClasspublic ActionForward execute(ActionMapping mapping,...............)
    if(a==view)
    return mapping.findForward("success");
    else
    return mapping.findForward("success1");
    ----------------Struts-config.xml------------
    <form-beans>
    <form-bean name="viewdownloadForm" type="ViewdownloadForm"/>
    </form-beans>
    <action-mappings>
    <action path="/Select"
    name="viewdownloadForm"
    type="ViewdownloadAction"
    input="/Select.jsp">
    <forward name="success" path="/Success.jsp"/>
    <forward name="success1" path="/Success1.jsp"/>
    </action>

  • Two idocs with same idoc number in idx5

    We are using an idoc to file scenario where idocs are bundled using bpm and posted to ftp. here the issue is we are getting two idocs with same idoc number in idx5. due to which the file in ftp is getting overwritten.
    Could anyone suggest me what to do in this regard.

    Hi,
    >>>check your sender system is sending same IDoc twice ?
    if you send the same IDOC twice they both get different numbers as IDOC number is taken from the IDOC num range
    unless you're able to send the same IDOC twice with the same IDOC num somehow
    Regards,
    Michal Krawczyk

  • Two account with same UPN in Active Directory

    Is it possible to have two accounts with same UPN in AD? 
    I'm using Windows Server 2012 R2

    To expand on what Mr X said. Active Directory allows you to assign just about anything to the userPrincipalName attribute, as long as the value is unique. The value of this attribute is generally referred to as the UPN. But you could assign values with no
    "@" symbol, for example, or more than one "@" symbol. Also, Active Directory does not require that any value be assigned. It is an optional attribute.
    If no value is assigned to the userPrincipalName attribute, then the user can use a "default" UPN, which is <sAMAccountName>@<DNS domain name>, where <sAMAccountName> is the "pre-Windows 2000 logon" name of the user
    (the value of the sAMAccountName attribute), and <DNS domain name> is the DNS name of the domain.
    If a user has a value assigned to userPrincipalName that does not match this "default" form, then they can logon with either UPN, as long as no one else has either value assigned to their userPrincipalName attribute. You will note that Active
    Directory enforces uniqueness in the domain on sAMAccountName values.
    If in domain "domain.com" a user has a sAMAccountName of "jsmith" but userPrincipalName "[email protected]", then another user can have userPrincipalName of "[email protected]" (as long as no one else
    has that value assigned to userPrincipalName). They can each logon with their assigned values for userPrincipalName. But the first user can no longer also logon with their "default" value, based on their sAMAccountName, because it is now
    used by someone else. But if you attempt to assign a value to userPrincipalName that is also assigned to another user, you get an error.
    Bottom line, only one person can logon with any given UPN.
    Richard Mueller - MVP Directory Services

  • Two records with same  key (Infocube)

    Hi,
    I was trying to do, in a update rule, an "IF" condition with two key figures.
    IF Kf1 > Kf2. result = Kf1 else result = Kf2.
    But the data in the source (datamart Infocube to infocube) have tow records with the same characteristics combination (the same keys)and different amount in the keyfigures, then the result of my "if" condition is not the expected because I understood in the infocube only exists one characteristics combination. :S
    I was seeing those records in the manage transaction of the infocube.
    Some reason for this?
    Thanks and regards
    Victoria Leó

    This can happen with parallel loads.  Two rows with same set of Char values but in different packets of the same Request, being loaded at the same time.
    It really shouldn't be an issue - your update rule will make the KF change as desired.  Your queries aggregate KFs based characteristic values, not Dim IDs, so you'll get the totals you expect.
    Here's some more info:
    There is an RSRV Test that lets you check a dimension for a cube to see if multiple DIM IDs exist for the same combination of Chars - <b>Multiple Entries in Dimensions of a (Basis) InfoCube</b>
    Output looks like:
    12:02:24 o'clock on 08/25/2006: Start test run for user PIZZAMAN:)
    Dimension ZFM_C521: DIMID 61,215 and 61,214 have same characteristic values
    Dimension ZFM_C521: DIMID 61,880 and 61,879 have same characteristic values
    Dimension ZFM_C521: DIMID 61,366 and 61,365 have same characteristic values
    Dimension ZFM_C521: DIMID 61,368 and 61,367 have same characteristic values
    12:02:24 on 08/25/2006: Test run for user PIZZAMAN:) completed
    You can run the Correct Error option to have it update fact rows to use one of the DimIDs if you want, but unless you have lots of them, I even wouldn't bother.
    Here's the description of the test:
    <u>Description</u>
    This elementary test recognizes whether there are several lines that have different DIMIDs(dimension table key), but have the same SIDs for the selected dimension table for the InfoCube specified. (This can occur by using parallel loading jobs). This has nothing to do with an inconsistency. However, unnecessary storage space is occupied in the database.
    <u>Repairs</u>
    Since the different DIMIDs with the same SIDs are normally used in the fact tables, they cannot simply be deleted. Therefore, all of the different DIMIDS in the fact tables are replaced by one DIMID that is randomly selected from the equivalent ones. Before a change can be made to the database, the consent of the user is requested.
    DIMIDs that have become unnecessary are deleted in the connection. In doing so, not only are the DIMDs deleted that were released in the first part of the repair, but so are all of those that are no longer used in the fact tables (including aggregates). The consent of the user is again requested before this change is made.

  • Unable to monitor two databases with same name on two different hosts

    I have got two databases with same name on two different hosts. I added one database to the list of monitored databases. Now If I try to add the other one , I get the message that the database is already being managed.
    Can't we monitor two databases with same name on two different hosts?

    you can... while saving the target,give a different name.. for eg target-2

  • Class extends two interface which have method in common name

    A class implements two interfaces. Those interfaces have method in common name.
    For ex;
    public interface b{public void hello();}
    public interface c{public void hello();}
    public class a implements b,c
    public void hello(){}
    Since two interfaces have common method, How to differentiate in this case ?

    How to differentiate what? You have to provide a method called hello(), just as in your example. (Normally you would have code in the method body, but zero lines of code is not against the rules.)

  • How to separate two contact with same name

    Hi, anyone knows how to separate two contacts with same name in Contacts?  Actually they are two persons from two gmail contacts with same name but different contact numbers, different emails....etc, but Contacts assume they are same person and merge them as one!

    FG,
    In Lion, you have the File > Duplicate option. You will then have two copies of your document open, and the one on top will have the temporary filename "OriginalFileName copy", and your next responsibility is to File > Save (or Command-S) and rename the duplicate. At this point, you edit the copy's name, to perhaps ...copy 1, or whatever you wish. The document you had open when you initiated the File > Duplicate will still be there on your screen, waiting for you to Close it or continue editing.
    Jerry

  • HT5622 Good day!! I was having two Iphones with same icloud id, later i deleted 1 id from one device, and made 2nd id for this device but same time my old id is stored on other device and i can not change it with another id, can any1 guide me on this issu

    Good day!! I was having two Iphones with same icloud id, later i deleted 1 id from one device, and made 2nd id for this device but same time my old id is stored on other device and i can not change it with another id, can any1 guide me on this issue.

    Log in to icloud.com on a web browser and remove the device from "Find My iPhone"

Maybe you are looking for