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

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

  • [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...

  • How To Create Table View With Same Column name But Different Table?

    Hi All,
    I have the problem to create a tableview with same column name but in different table.
    The Table that i have:-
    Table - PAC051MPROFORMA
    Column - mrn,visitid
    Table - PAC051TPROFORMA
    Column - mrn,visitid
    Table - PAC052MTRANSBILL
    Column - mrn,visitid
    Then i want to create a table view to view that table. This is my SQL
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    That SQL Return this error = ORA-00957: duplicate column name
    Then I modify that SQL to
    CREATE VIEW pacviewproforma (mrn,visitid)
    As Select PAC051MPROFORMA.mrn,PAC051MPROFORMA.visitid,PAC051TPROFORMA.mrn,PAC051TPROFORMA.visitid,PAC052MTRANSBILL.mrn,PAC052MTRANSBILL.visitid
    where
    *(a.PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)*
    and
    *(a.PAC051TPROFORMA.mrn=PAC052TRANSBILL.mrn)*
    This time this error return = ORA-01730: invalid number of column names specified
    What should i do?
    Thanks...

    Hi,
    SQL> CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    CREATE VIEW pacviewproforma (mrn,visitid,mrn,visitid,mrn,visitid)
    ERROR at line 1:
    ORA-00957: duplicate column namePlease give different names to each column.
    Something like this..
    SQL> CREATE OR REPLACE VIEW pacviewproforma (MPROFORMA_mrn,MPROFORMA_visitid,TPROFORMA_mrn,TPROFORMA
    _visitid,MTRANSBILL_mrn,MTRANSBILL_visitid)
      2  As Select
      3  PAC051MPROFORMA.mrn,
      4  PAC051MPROFORMA.visitid,
      5  PAC051TPROFORMA.mrn,
      6  PAC051TPROFORMA.visitid,
      7  PAC052MTRANSBILL.mrn,
      8  PAC052MTRANSBILL.visitid
      9  from PAC051MPROFORMA,PAC051TPROFORMA,PAC052MTRANSBILL
    10  where
    11  (PAC051MPROFORMA.mrn=PAC051TPROFORMA.mrn)
    12  and
    13  (PAC051TPROFORMA.mrn=PAC052MTRANSBILL.mrn);
    View created.
    SQL> DESC  pacviewproforma;
    Name                                      Null?    Type
    MPROFORMA_MRN                                      NUMBER
    MPROFORMA_VISITID                                  NUMBER
    TPROFORMA_MRN                                      NUMBER
    TPROFORMA_VISITID                                  NUMBER
    MTRANSBILL_MRN                                     NUMBER
    MTRANSBILL_VISITID                                 NUMBER
    ORA-01730: invalid number of column names specifiedThe list of column nmae you specified during the CREATE VIEW should match with the SELECT list of the view.
    Twinkle

  • 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

  • Multiple Infoobject with same technical name

    Hi All,
    I have a very basic question which confuses me a lot.
    I have installed a BI content info cube 0SD_C03(Sales overview) and it is installed in Info Area -  ERP Analytics -->sales and distribution analyses. I checked the dimensions of it and 0customer( master data attr) is linked as a dimension. I created a copy of 0SD_C03 and the new Infocube name is ZSD_C03_T. It also has the same 0customer master data attr as a dimension(obviously!).
    Now both the infocubes have different technical name(0SD_C03 and ZSD_C03_T) since they will be storing different sets of data(lets say). but the technical name of the master data (0CUSTOMER) is the same for both cubes.
    ques 1: Is it since its a master data and contains the same set of master data for both the cubes, it has the same technical name?
    If I search the Info provider section for "0CUSTOMER", i get two entries: One within my info area and another within another info area. And also i can keep doing (Right click Info area--> Insert Characteristic as Infoprovider) on every other info area and insert 0CUSTOMER in every other info area.
    ques 2: does all the 0CUSTOMER in different info areas, actually contain the same set of data?
    ques 3: if i search for 0CUSTOMER in InfoObjects section, i get 5 entries in different infoareas. How can there  be diffferent Infoobject with same technical name be present in different info areas?
    Sorry if i am too elaborate, I hope i have made my questions clear.

    Hi,
    ques 1: Is it since its a master data and contains the same set of master data for both the cubes, it has the same technical name?
    A. same 0CUSTMER you can use the different places it holds same data.
        source is the 0CUST_ATTR -> target is 0CUSTOMER.
    ques 2: does all the 0CUSTOMER in different info areas, actually contain the same set of data?
    A. it will contain the same set of data.
        it has the overwrite function.
    ques 3: if i search for 0CUSTOMER in InfoObjects section, i get 5 entries in different infoareas. How can there  be diffferent Infoobject with same technical name be present in different info areas?
    A. you triggered the 5 times for specif DTP means you will 5 entries for different info areas.
    finally i will say you use the 0CUSTOMER no of places where you required and no need to create the ZCUSTOMER.
    Thanks,
    Phani.

  • Two query with same technical name in Quality

    Hi experts,
    I have two queries in Quality with same technical name. I used the program RENAME_DUPLICATE_ELEMENTS to rename the query and its renaming the latest query instead of the old Query. I am in BI 7.0 system and cant find a note that applies to BI 7.0. There are quite a few notes on 3.x system. Has somebody faced the same problem. What did you do. If there is a note for bi 7.0, please let me know so i can resolve with the Basis team.

    We had similar issues - this happens when you create a query locally and then transport the same.
    The queries have an internal GUID which is generated locally and this causes duplicates.
    You can :
    1. Delete queries using the GUIDS ( you can find this in RZCOMPDIR or RSRREPDIR tables ) using RZDELETE to delete queries.
    identify your older version query and then delete the same and you should be good to go...
    also try identifying the same using program
    ANALYZE_RSZ_TABLES

  • How to get two fields with same tech name in LIS Extractors?

    Hi Experts,
    I need "ERDAT" field from two structures (QMSM & QMFE) in 2LIS_18_IOTASK extractor.
    In LBWE first I moved ERDAT from QMSM. When I moved ERDAT from QMFE it gives an error:
    "Field with same technical name is already available in the Extract Structure".
    I don't want to create Append Structure as we need to write User exit.
    Can any one tell me how to get this field added in the extractor from QMSM and QMFE?
    Thanks for your help.
    Regards,
    Sree

    this is not possible as the all those fields are put in one structure. per definition you can't put the same field name twice in a structure, table in the data dictionary...
    hence, you really need to use an append and fill via user exit
    M.

  • How can OIM provision users with same Display Name in AD?

    I can create users with same First Name, Middle Name and Last Name (same Display Name) in OIM if they have different UserId.
    But I can not provision two users with same Display Name to one Organization Unit in AD, the resource provisioning shows
    Status: Rejected
    Response: AD user already exists
    Can AD be configured to create users with same Display Name (different UserId) in one OU, or would I have to create logic in OIM to modify the display name so it gets accepted by AD?
    Thanks!

    Thanks Nitesh. Also, I can create the user with same DN in different OU's, not in same OU.
    I agree once we determine that same cn exists in one OU , I can modify the display name by appending a number at the end or something. I understand the logic but I need more details on how to specify this logic in the pre-pop adapter, can you please share more details.
    Thanks a lot!

  • Recreate skype user with same skype name ?

    I just deleted 21 skype users, by mistake, in Business Manager, is it possible to recreate them with same skype name ?
    /Claus

    Hi again,
    Hope this helps.
    alias_maps = hash:/etc/postfix/aliases,hash:/var/mailman/data/aliases
    always_bcc =
    command_directory = /usr/sbin
    config_directory = /etc/postfix
    content_filter = smtp-mailtransport:[127.0.0.1]:10024
    daemon_directory = /usr/libexec/postfix
    debugpeerlevel = 2
    enableserveroptions = yes
    inet_interfaces = all
    luser_relay =
    mail_owner = postfix
    mailbox_transport = cyrus
    mailq_path = /usr/bin/mailq
    manpage_directory = /usr/share/man
    mapsrbldomains =
    messagesizelimit = 10240000
    mydestination = $myhostname,localhost.$mydomain,localhost,apm.pt,onlearn.apm.pt,ml.apm.pt,xserv e.apm.pt
    mydomain = apm.pt
    mydomain_fallback = localhost
    myhostname = mail.apm.pt
    mynetworks = 127.0.0.1/32,195.23.139.104/29
    mynetworks_style = host
    newaliases_path = /usr/bin/newaliases
    ownerrequestspecial = no
    queue_directory = /private/var/spool/postfix
    readme_directory = /usr/share/doc/postfix
    recipient_delimiter = +
    relayhost =
    sample_directory = /usr/share/doc/postfix/examples
    sendmail_path = /usr/sbin/sendmail
    setgid_group = postdrop
    smtpdclientrestrictions = hash:/etc/postfix/smtpdreject
    smtpddelayreject = yes
    smtpdenforcetls = no
    smtpdhelorequired = yes
    smtpdhelorestrictions = permitsasl_authenticated,permitmynetworks, checkheloaccess hash:/etc/postfix/heloaccess,reject_non_fqdn_hostname,reject_invalidhostname,permit
    smtpdpw_server_securityoptions = login
    smtpdrecipientrestrictions = permitsasl_authenticated,permit_mynetworks,reject_unauthdestination,permit
    smtpdsasl_authenable = yes
    smtpdsenderrestrictions = permitsasl_authenticated,permit_mynetworks,reject_non_fqdn_sender,reject_unknown_sende rdomain,permit
    smtpdtlsCAfile =
    smtpdtls_certfile =
    smtpdtls_keyfile = $smtpdtls_certfile
    smtpdtlsloglevel = 0
    smtpduse_pwserver = yes
    smtpdusetls = no
    unknownlocal_recipient_rejectcode = 550
    virtualaliasmaps = hash:/var/mailman/data/virtual-mailman
    João.

  • WLS 7 - IIOP - Remote interface with parameterless method

    Hi all,
    I am developping EJBs which are accessed by clients with IIOP.
    Every method without any paramter I put in the remote interface do not
    work with IIOP but are ok when I call with T3.
    Note that all other methods which have parameters work properly.
    The EJB (Stateless SessionBean) is well deployed and installed on the
    server,
    ejbc gives no error.
    The resulting stacktrace on the client is :
    java.rmi.RemoteException: CORBA BAD_OPERATION 0 No; nested exception
    is:
    org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
    java.rmi.RemoteException: CORBA BAD_OPERATION 0 No; nested exception
    is:
    org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
    org.omg.CORBA.BAD_OPERATION: minor code: 0 completed: No
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Class.java:237)
    at com.sun.corba.se.internal.iiop.ReplyMessage.getSystemException(ReplyMessage.java:93)
    at com.sun.corba.se.internal.iiop.ClientResponseImpl.getSystemException(ClientResponseImpl.java:83)
    at com.sun.corba.se.internal.corba.ClientDelegate.invoke(ClientDelegate.java:204)
    at org.omg.CORBA.portable.ObjectImpl._invoke(ObjectImpl.java:459)
    at ch.vd.collectivitespkg._Collectivites_Stub.getTypesCollectivites(Unknown
    Source)
    at ch.vd.testpkg.CollectivitesTestClient.getTypesCollectivites(CollectivitesTestClient.java:467)
    at ch.vd.testpkg.CollectivitesTestClient.testRemoteCallsWithDefaultArguments(CollectivitesTestClient.java
    :502)
    at ch.vd.testpkg.CollectivitesTestClient.main(CollectivitesTestClient.java:545)
    At the same time only one line is added to the server log :
    ####<Jun 12, 2003 4:33:52 PM CEST> <Info> <IIOP> <****> <Server>
    <ExecuteThread: '14' for queue: 'default'> <kernel identity> <>
    <002002> <Failed to parse method name getTypesCollectivites.>
    FYI : I am using Jbuilder 7.0 with JDK 1.3.1-b24 and WLS 7.0 SP1.
    Thanks in advance for your help.
    Chris.

    [email protected] (ChrisFR) writes:
    Here is the fragment of the (new-)remote interface concerned :
    public Collection getTypesCollectivites(int type) throws
    RemoteException, BusinessException;
    BusinessException is not a runtime exception, it extends Exception.
    Where can I have a look on bugfixes in SP2 and SP3 ?Yes, we just fixed this. The CR is CR108317, if you go through support
    you will be able to get a patch. This will appear in sp3.
    andy

  • "Accounting-Start" and "Accounting-Stop" with same "user name" and "session Id" recorded in different RADIUS servers.

    Hi,
    I have questions about "Accounting-Start" and "Accounting-Stop".
    1.If a NAS configured to have a primary and a backup RADIUS server. To start with all the “Accounting-Start” records will be in the primary RADIUS server. Later on the primary server goes down (Primary server won’t tell the NAS?). When sessions stop, the NAS sends the “Accounting-Stop” to the secondary. I understand the “Start-Stop” record with the same “user name” and “session-id” ideally should be recorded in the same server. If this situation happens what should both the NAS and RADIUS server do?
    2.A NAS configured to have a primary and backup RADIUS server. To start with all the “Accounting-Start” records will be in the primary RADIUS server. Later on the administrator decided to change the primary server (as there are problems with the previous primary). sessions stop, the NAS sends the “Accounting-Stop” to the new primary. This ends up the “Accounting-Start” and “Accounting-Stop” with the same “user name” and “session Id” in two RADIUS servers.
    To summarize, how to avoid the ”start-stop” pair ends up in different servers ? If it does, is it  an issue for RADIUS application ?
    Cheers,
    1.If a NAS configured to have a primary and a backup RADIUS server. To start with all the “Accounting-Start” records will be in the primary RADIUS server. Later on the primary server goes down (Primary server won’t tell the NAS?). When sessions stop, the NAS sends the “Accounting-Stop” to the secondary. I understand the “Start-Stop” record with the same “user name” and “session-id” ideally should be recorded in the same server. If this situation happens what should both the NAS and RADIUS server do?
    2.A NAS configured to have a primary and backup RADIUS server. To start with all the “Accounting-Start” records will be in the primary RADIUS server. Later on the administrator decided to change the primary server (as there are problems with the previous primary). sessions stop, the NAS sends the “Accounting-Stop” to the new primary. This ends up the “Accounting-Start” and “Accounting-Stop” with the same “user name” and “session Id” in two RADIUS servers.
    To summarize, how to avoid the ”start-stop” pair ends up in different servers ? If it does, is it  an issue for RADIUS application ?
    Cheers,

    vignesh and BalusC,
    following is the code in front controller's doFilter method. is this not thread safe?
            HttpServletRequest req = (HttpServletRequest) request;
            HttpServletResponse res = (HttpServletResponse) response;
            HttpSession session = req.getSession();
            somepackage.User user;
            if(session.getAttribute("user") == null){
                user = new somepackage.User();
                session.setAttribute("user", user);
            }else{           
                user = (somepackage.User) session.getAttribute("user");
            }user object maintains all information about a user. if it is in session scope, everything should work fine.
    another observation is after some time of usage, both people in different systems are getting same session.getId()
    in my logout page i am using
    session.invalidate();
    thanks,
    moses

  • Getting old site off the 'net without appropriate files. (to start over with same domain name)

    As a complete novice, I'm not even sure how to start this question...but, I have tried everything and I think I have "lost" my website in terms of bringing in back into DW and changing/updating it.  My backup files on my computer have disappeared and the appropriate files through my cPanel to bring it back to in order make changes aren't there.  The website still functions, but it is outdated for my business needs.
    So, at this point, my question is this; how can I gain control over the domain and start over from scratch.  I don't want what is out there anymore, but without control through the above mentioned devices, is it even possible to build a new website and get the old one off the 'net as it is and still keep the original www.name.com?
    I'm clueless at this point.  Thanks.

    Chazmonk wrote:
    So, at this point, I don't know what is really going on.  My main goal was to get my existing website off the net and put something updated on with the same domain name.  I was successful with what JTANNA suggested, but I don't know what I'm doing with a mirrored site in terms of what my needs are.  I am not against changing the domain name and just leaving this one out there, though I did put a great deal of time into building it.  I would take some further help if anyone has more suggestions, but I'm about ready to move one.
    Thanks for trying to help.
    You will need to sort out the FTP issues because when you have edited your site, you will need to upload it and so FTP details will be required.
    Your first port-of-call to sort this out is to contact your host who can reset the password for you so that you can start all over again.  The alternative, is to give your password/login details to Murray (PRIVATELY) so that he can try from his machine.  When this is done, you can always change the password for your own security.
    hth

  • Interface with static methods

    I'm writting a wrapper for exception handling.One of the classes uses log4j to log exceptions.I want to write a interface to generalize loggin.Idealy I should have an interface with certain static methods for loging (i.e logError,logDebugMessage,consoleError,consoleMessage,etc) , but Interface dosent allow that and neither do abstract classes can havstatic method declarations.The implementations of these methods will achieve the hiding of the complexity of using a logging package,log levels etc from the user.
    Let me know how best I can work something out for this.
    Thanks in advance

    Define them once (as final) in an abstract class. Then any subclass can call logError etc.
    Kind regards,
      Levi

  • Combine Files into a Single PDF with Same File Name

    I have one PDF form that I have to fill in some data and a Microsoft  Word Document.   Sometimes I wait a few days so I need to complete the same PDF form.  When I combine them, I get warning that PDF forms with the same name will be the same - if I do not want this, I should create a PDF portfolio.  The portfolio does not see like I want.  It combines the PDFs into some else.
    I could change the names of the fields that I need, but I am sometimes afraid that I missed something.
    Is there a way to get away with this issue so the combination is good?  I have to fax the documents in once created and the portfolio does not seem like I can do that.
    Adobe Acobat XI Pro and Windows 8.1
    Thank you!
    Corey

    So I think I found it - you go to File - Save As Other - Discard and then check Flatten form fields.  The fields can be changed (but that is fine, I am faxing the pages). 
    So I guess I am trying to verify, is this the correct way?
    I ask because I found Eight Free Acrobat XI Actions for Legal Pros that leads me to down a .sequ file extension.
    If the first one is correct, and I have a PDF page that needs to be used twice in the combination, this will work?  And that data field (say 9ROW OF SERVICE) the first page can have 01/22/2014 and the second will have 01/23/2014?  I just want to make sure because before when I reviewed the Binder, if I entered 01/23/2014, then the other PDF page has the incorrect date of 01/23/2014 instead of 01/22/2014.  I ask this as well because sometimes I might have to change the date or something else in a field with the same field name, and that other PDF file will update.
    Thank you!
    Corey

Maybe you are looking for