How to achieve polymorphisim using composition

How to achieve polymorphisim using composition

Not possible. This is very wrong, polymorphism is very much facilitated by Composition (or Aggregation).
Polymorphism goes hand in hand with
either imlementing an interface or extending a class.The fundamental objective of Polymorphism is the handling/using Objects of multiple types in a uniform manner, i.e. to a fixed contract.
Composition may be used to delegate the
implementation of an interface or subclass' method.Composition allows much more than delegation, it about defining a static contract between two objects.
composition itself is not polymorphic.The main difference between simple composition and polymorphism is the valence. In Polymorphism it is explicityly 1. .N in the case of composition it is implicitly 0..N
I think this code proves that a Composition of classes for Odd and Even can be used polymorphically.
public class Polymorphism {
  abstract public class Base {
    public void method()
      System.out.println( this.getClass().getName() + ".method()" ) ;
  public class Odd extends Base {
  public class Even extends Base {
  final int ARRAY_SIZE = 10;
  Base[] composition = new Base[ARRAY_SIZE] ;
  public Polymorphism() {
    for(int i = 0 ; i < ARRAY_SIZE ; i+=2 )
      composition[i] = new Even() ;
      composition[i+1] = new Odd() ;
  public void process() {
    for(int i = 0 ; i < ARRAY_SIZE ; i++ ) {
      composition.method() ;
public static void main(String[] args) {
Polymorphism polymorphism = new Polymorphism();
polymorphism.process() ;

Similar Messages

  • How to achieve this using UWL

    Hi Friends,
    I have the following requirement for Travel request workflow and Invoice approval workflow. Please let me know how to achieve this.
    While sending a work item to sap inbox we will put the base BO in the task container right so that the approver can open the particular transaction.I need the same functionality in UWL but instead of the BO i need to place some link so that the user can open an iview or webdynpro application. Basically the user dont want to login to SAP GUI he needs everything to be done in Portal itself.
    Do we need to do some settings in tcode SWFVISU for this or do we need to change the associated xml file in UWL to provide the link to iview. Please advice.

    Hi,
    If i understand your requirement correctly, you want to place a link of BO in UWL but don't want that to get to SAP GUI. Right ?
    I think it's possible. We had ECC 6.0 and EP 6.0 with SP 11. And, we had the requirement of showing up the TRIP BO in UWL thru' an iVIEW. We tried the SWFVISU and it didn't work. But, i think this facility has been taken care in later service packs. Pl approach SAP and they should be able to help you out. I'm not sure about the details of the solution SAP provided us, but it worked for us..like there will be a button "Display XXXXXX" which infact opens up your BO in UWL without logging into GUI.
    Hope this helps.
    venu

  • How to achieve image using digital camera of USB-type interface through IMAQ PCI-1424 board.

    1.Is it doable?
    2.How to connect USB-type interface with IMAQ PCI-1424 board.
    Thanks!

    See the Developer's Zone (www.ni.com/zone) for specifics on USB (search for "USB").
    "1.Is it doable?"
    - In short "no".
    - USB is similar to FireWire (IEEE 1394), and no framegrabber is required. We offer an IEEE 1394 IMAQ driver to interface FireWire cameras with LabVIEW & CVI.
    "2.How to connect USB-type interface with IMAQ PCI-1424 board."
    - You will need a USB driver for the camera. The 1424 is not required.

  • Pie Chart with a separated pie - How to achieve in WD ABAP

    Hi Experts,
    My requirement is to create a pie chart and separate a pie depending upon the user logged in. To explain, I will take example of a leave request. A leave request goes throgh 3 approvals i.e 3 different departmens. The graph should show the no of requests per department. Depending upon the user logged - his dept. pie should be highlighted or separated. How to achieve this using webdynpro abap.
    Thanks in Advance.
    Best Regards,
    Aleem Mohiuddin.

    Hi,
    you can achive this using FlashIsland UI element.
    refer Adobe Flash Islands Integration SAP help,
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/1b/eac5a6dc724b5cb7a6cc6b91fbbd64/frameset.htm
    Thanks,
    Chandra

  • How to achieve parent-child relationship using self join?

    my table structure is as follows
    parent child name
    -1     1     A1
    1     2     A2
    1     3     A3
    how to achieve the hierarchy model using self join. this can be easily achieved using "connect by prior". but how to achieve the same using self join?

    Hi,
    Yes, that's definitely possible. If you only need to display two levels from the hierarchy, a self-join is a good option. Make it an outer join if you need to show everyone on one level, regardless of whether they have a match on the other level or not; for example, if you want the output:
    child_name     child_id     parent_name     parent_id
    A1          1
    A2          2          A1          1
    A3          3          A1          1It's good that you posted some sample data. Now post the results you want from that data, and your query (what you think is the best attempt you've made so far). If you haven't tried anything so far, then look at some other simple self-join to get ideas.

  • How to achieve Incremental deployment of Code Files to different environments of windows azure using TFS and Visual Studio ?

    Hi
    We are new to Windows azure and are developing a web application. In the beginning of the project , we have deployed complete code using Sitefinity Thunder to different environments which actually publish complete code. But now as we are in the middle of development
    , we are just required to upload any new files created which can be quite less in numbers (1 or 2 or maybe few). Now if we deploy with thunder , it publishes all files and then deploys complete code which takes good amount of time. Hence we are thinking to
    attach each Azure Cloud Service which is actually a different environment like staging, UAT to a TFS branch and then just check in code from local development machine to TFS and then deploy only checked in files to azure environment linked to TFS.
    I hope this possible but if you can help send some links where I can see how to achieve this , that will be helpful. 
    Also I would like to know whether a single cloud service can be linked to a single TFS branch or multiple cloud service can be linked to a single TFS repository? Why I am asking is – because we want to deploy a checked in files revision number to a staging
    cloud service and then will test there and then if everything works well then will be required to deploy these revision files to the next cloud UAT cloud service and then production cloud service. Please help.

    Hi,
    We can use TFS to manage our azure cloud service application code, refer to the following to get more information about how to deploy sitefinity to azure.
    #http://www.sitefinity.com/documentation/documentationarticles/manually-deploying-your-project-to-windows-azure
    #http://www.youtube.com/watch?v=E2aZ7lE1JUA
    #http://www.sitefinity.com/documentation/documentationarticles/sitefinity-azure-configuration
    If any question about sitefinity, please redirect to sitefinity forum:
    http://www.sitefinity.com/developer-network/forums if the issue was related with azure, welcome to post again.
    Best Regards
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to achieve modularize in flex using cairngorm framework?

    Hi,
    I have seen many articles on flex and cairngorm but haven't found enough information on how to achieve modularization in flex using cairngorm framework.
    Please let me know any information regarding this.
    Thanks in advance.
    Vishnu

    Hi Sumit,
    I am also working similar kind of requirement. In my case I tried to add new tab subtab using personalization , how ever the add new item button is not enable.
    So I created new stacklayout and tried to add this to new tab in the existing subtablayout by using co process form request code:
    public void processRequest(OAPageContext oapagecontext, OAWebBean oawebbean)
    super.processRequest(oapagecontext, oawebbean);
    OracleCallableStatement oraclecallablestatement = null;
    OracleConnection oracleconnection = (OracleConnection)oapagecontext.getApplicationModule(oawebbean).getOADBTransaction().getJdbcConnection();
    try{
    oracleconnection.setAutoCommit(true);
    oraclecallablestatement = (OracleCallableStatement)oracleconnection.prepareCall("begin GLO_TMPVIJ_PRCV(:1); end;");
    oraclecallablestatement.setString(1,"In the custom co process request");
    oraclecallablestatement.execute();
    }catch(SQLException sqlexception)
    throw OAException.wrapperException(sqlexception);
    OASubTabLayoutBean subTabLayout =
    (OASubTabLayoutBean)oawebbean.findChildRecursive("ApplicationDetsTabLayout");
    OASubTabBarBean subtabbar = (OASubTabBarBean)oawebbean.findIndexedChildRecursive("subTabBar");
    OALinkBean link = (OALinkBean)oapagecontext.getWebBeanFactory().createWebBean(oapagecontext,
    OAWebBeanConstants.LINK_BEAN, null,
    "link");
    OAStackLayoutBean commentsRN =
    (OAStackLayoutBean)oapagecontext.getWebBeanFactory().createWebBean(oapagecontext,
    "/xxhr/oracle/apps/irc/candidateManagement/webui/CommentsRn",
    "CommentsRn", // always specify name
    true); // region created in Oracle9i JDeveloper OA Extension
    subTabLayout.addIndexedChild(commentsRN);
    subTabLayout.addIndexedChild(link);
    in this I am not ale to add the new tab.
    Regards,
    Vijay Reddy.

  • How to achieve Check point functionality in SSIS with out using check point.

    I got question from
    interview!!! How
    to achieve Check
    point functionality in SSIS with out using check point. If package
    fails it has to be re-run from the point that it failed instead
    of rerunning the entire package.without
    using check point.
    Please
    any one can explain step by step...

    Sorry you have failed your interview question. Good thing you remembered it, thought about it, and ask a question about it. The solution is actually very straightforward.
    Create a table to store the state of your progress. Before each step read the table to find out where left off, then skip each completed step. After each step write to the table which step you have completed. A step can be anything, a task, a component,
    a row, an import file, an export file. You don't have to use a table, it could also be a file, just something you can read and write, and does not disappear when your package stops.
    If you find this difficult to comprehend, think of a checklist of things you do everyday and work from there.

  • How to achieve multiple hirearcy structure using RBS feature in Project server 2013

    HI,
    How can we achieve multiple hirearcy structure using RBS feature in Project server 2013?
    The below is the screen shot of hirearcy.
    GM
    DGM
    AGM
    CM
    Officers
    There are different departments and one AM may handle 4 or more department. How to achieve this permission levels so that GM can see all departments officers created project, same with other levels
    Thanks,
    Sunitha

    Hi Sunitha,
    You could populate the RBS lookup table with 2 levels (department and sub department). Then configuring correctly your
    security categories based on the RBS, the resources in the 1st level (departments) will see projects from all theirs sub departments.
    Some more references:
    http://aboutmsproject.com/project-server-securitypart-1/
    http://ntrajkovski.com/2012/06/04/the-rbs-lookup-table-in-ms-project-server-2010/
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • How do I make use of the Composite Video input jack on my HP pavilion Elite m9150f computer?

    I have a Pavilion Elite m9150f computer that has front panel jacks labeled "Composite Video Input,and Audio left and Audio right input" They are all RCA type.None of the PDF type manual files mention these jacks.I would like to make use of them to input video from either my old VCR that has the same output jacks and or a DVD player that is also equipped with the same set of output jacks.Finaly, I would like to know what programs should I use to view the video that I connect to these input jacks? Thanks for any and all ideas.

    If your m9150f still has Cyberlink DVD Suite Deluxe and the Hauppauge TV tuner installed, then you can use Cyberlink PowerDirector v6 to capture home videos from a VCR as MPEG2 movie clips (.mpg). The files can then be played using Windows Media Player or burned to disc using Windows DVD Maker. You can also edit the movie clips with PowerDirector or other video-editing software. MPEG2 video is not ideal for editing: there will be some loss of picture quality when the video is re-encoded. To minimize that, make your edited videos short and do not reduce the bit rate. Note: The jack on the back of the m9150f is Video Composite-01, the one on the front is -02. Be sure to select the right capture source in PowerDirector's Capture / Device Setup / Video Setup tab. I can't think of any good reason to use Composite jacks for DVD input as long as your m9150f has a functioning DVD drive.

  • How to delete the deployed composite in weblogic server 11g

    Can someone tell me how to delete the deployed composite in weblogic server 11g ?I'm facing an issue where the weblogic server is getting started and immediately after sometime the server changes to "Force shutdown"..When i checked the logs,there is an error in one of the composite i deployed..So now i wanted to delete the deployed composite?Please help ....
    Thanks

    Hi
    1. Deleting a domain will not hold any references. But make sure that under your user_projects/applications also remove the folder that matches with your domain. Basically under user_projects folder you will see 2 folders named applications and domains. When you create a domain say mySoaDomain, it will crate a folder with the same name under applications folder also with few files like em.ear. If you do this, then you can crate a new soa domain and use the same old name.
    2. NOW comes the most important thing. If you create a new SOADomain, at one point, you had to give details for soainfra and mds schemas. If you give your current existing db details (that was used for your old deleted domain), then you may still have the issues. Because the soainfra db may still have the instances for your old process.
    3. If you really want to have a full clean soa domain, here is what you do:
    a) Run rcu and drop the existing schemas for soainfra and mds.
    b) Run rcu again and create above schemas again.
    c) Now create SOADomain using config wizard and refer above clean rcu db and you are all set.
    3. Under your domain root folder, just searh for files named with your workflow and you should see the .jar location.
    Thanks
    Ravi Jegga

  • How to achieve automated posted for invoice and stock transfers

    Hi,
    I have following queries for an RFP, can some one give hints on how to achieve them in SAP
    o Receive self-billing documents from the customer, stating the deliveries and amounts that are settled and paid
    o Automatic posting of invoice documents from the vendor, based on the data from the purchase order and goods receipts
    o Process material stock transfers between two plants that use different SAP systems
    Thanks & Regards
    Raghu

    Hi,
    Normally when we do GR we take the cenvat credit by capturing & posting the excise invoice.
    This can be done using the t.codes - MIGO or J1IEX.
    So when the Material doc is posted the Part 1 register gets updated with Qty received.
    If we post the excise inv using either MIGO or J1IEX the Part 2 register gets updated.
    Now if you have done both the above then inorder to cancel the excise inv.
    1. You have to cancel the Material Doc (so system wil use the Mov type 102)
    2. Now Post your excise inv using J1IEX so that your Part1 reg will be updated ( i.e you are reversing the Cenvat Credit that you have availed).
    3. Finally you have to cancel the Excise inv document using J1IEX so that your Part 2 register wil be updated.
    Make sure that you do the above steps as per the above sequence else system will show the error as you mentioned.
    Hope its clear.
    Regards,
    Kiran

  • Search criteria is not working in Responsible Group field in sap crm could you please help me this how to achieve.

    search criteria is not working in Responsible Group field in sap crm could you please help me this how to achieve.I have writen code on EH_ONSEARCH .as per below...what changess i need to do..and through partner function and adding the selection params please send the sample .
    code. partner funtction - ZRG DATA :
    DATA : lv_partner_fct type .
    types: begin of ty_resp,
           partner    type but000-partner,
           name_last  type but000-name_last,
           name_first type but000-name_first,
           mc_name1   type but000-mc_name1,
           mc_name2   type but000-mc_name2,
           end of ty_resp.
    DATA: lv_resp_bp type STANDARD TABLE OF ty_resp INITIAL SIZE 0,
           lw_resp_bp type ty_resp.
    IF lv_attr_name = 'Rgroup'.
    lr_entity->get_property_as_value( EXPORTING iv_attr_name = if_crm_srqm_uiu_const=>gc_attr_low
                                       IMPORTING ev_result = lv_low ).
    IF lv_low IS INITIAL.
    SELECT partner
           name_last
           name_first
           mc_name1
          mc_name2
    FROM but000 INTO table lv_resp_bp
    WHERE mc_name2 = lv_low and bu_group = '0010'.
    loop at lv_resp_bp into lw_resp_bp.
        lv_low = lw_resp_bp-mc_name2.
      lr_query_service2->add_selection_param( iv_attr_name = 'Rgroup'
                                                iv_sign = lv_sign
                                                iv_option = lv_option
                                                iv_low = lv_low
                                                iv_high = lv_high ).
      ENDLOOP.
    if lv_partner_fct = 'ZRG'.
      lr_entity = lr_iterator->get_next( ).
    CONTINUE.
    ENDIF.
    lv_attr_name = 'BU_PARTNER'.
    ENDIF.

    <b>You can acheive   this .... first by creating the search help exit    ... by  creating the maintaince  view   then   using it in the   Creation of the search help </b> ...
    see the link for attaching the view   to the serach help .
    <a href="http://">http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_elementary.htm</a>
    reward  points if it is usefull...
    Girish

  • How can we delete the composition which is created by AEGP_CreateComp()?

    Hi,
    I have created a composition using AEGP_CreateComp( ) method under PF_Cmd_SEQUENCE_SETUP command. The composition is displaying in project folder. I have to delete the same composition from project folder under PF_Cmd_SEQUENCE_SETDOWN command.
    we can delete the layer using AEGP_DeleteLayer( ), but how can we delete a composition from project folder which is created by AEGP_CreateComp( )?

    Im getting the crash on 10th line when I delete the composition
         PF_Err err = PF_Err_NONE;
        AEGP_ItemH    item = NULL;
        AEGP_ItemType itemType;
        AEGP_SuiteHandler suites(in_data->pica_basicP);
        err = suites.CompSuite6()->AEGP_GetItemFromComp(compPH, &item);   
        if (item != NULL)
            err = suites.ItemSuite6()->AEGP_GetItemType(item, &itemType);
            if (itemType == AEGP_ItemType_COMP)
               err = suites.ItemSuite6()->AEGP_DeleteItem(item);
    What could be the reason?

  • How to achieve BC4J stateful management in a web app?

    I have a web application developed with JSP, Struts as the view / controller layer and BC4J as the model layer.
    I am not using the complete ADF framework. Just plain struts, JSP and BC4J.
    What I want to do is to have one struts action to set a
    query condition on a view object and execute the query.
    Then i release the application module. In another struts action I want to get the same application module with the
    viewobject query set.
    Pseudo for Action 1:
    try{
    Configuration.createRootApplicationModule("test.bc.AppModule", "AppModuleLocal");
    .. get view object
    .. build and perform the query on the view object.
    finally
    Configuration.releaseRootApplicationModule(am, true);
    pseudo for action2:
    try{
    Configuration.createRootApplicationModule("test.bc.AppModule", "AppModuleLocal");
    .. get view object with the query stored
    .. use the results.
    finally
    Configuration.releaseRootApplicationModule(am, true);
    I cannot make this work. If I put the am from action1 in the session object and retrieves it from the session in action2 it works. But I need to release the appmodule in action 1 since I have no guarantees that the user will run action2..
    I have read the paper of Steve Muench "Understanding Application Module Pooling Concepts and: Configuration Parameters"
    This document says:
    "ADF application modules provides the ability to snapshot and reactivate their pending state to XML (stored on the file system or in the database), and the ADF application module pooling mechanism leverages this capability to deliver a "managed state" option to web application developers that simplifies building applications like the example just given.
    As a performance optimization, when an instance of an AM is returned to the pool in "managed state" mode, the pool keeps track that the AM is referenced by that particular session. The AM instance is still in the pool and available for use, but it would prefer to be used by the same session that was using it last time because maintaining this so-called "session affinity" improves performance.
    I have set my bc4j configurations to
    releasmode = STATEFUL
    jbo.passivationstore = databse
    jbo.server.internal_connection= my jdbc connection
    But the appmodule returned in action2 is not the same as the one returned in action1.
    I am using jdev 9052 and deploying to oc4j 904 standalone.
    I guess I have to use som other commands for retrieving/ releasing the AM or set some properties on it, but I have not found any documentation for this.
    Any tips on how to achieve this bc4j session state to work in a plain struts , bc4j environment is appreciated.

    The Configuration.createRootApplicationModule() and companion releaseRootApplicationModule() API's are not for use in web applications. They are designed for use by simple command-line console programs.
    Using the BC4J application module pool programmatically in a web environment should be done like the JDeveloper 9.0.3/9.0.4 "Pooling" sample illustrates.
    In the JDev 9.0.3 or 9.0.4 version, see the sample project under ./BC4J/samples/Pooling
    Hope this helps.

Maybe you are looking for

  • Menu problem in ALV.....have ur ponts...

    Hi all, I copied standard SAP menu in Se41 then i used that in my ALV grid, Now i want to put my own function code on the exit button(red one), and in user command i m trapping that function code, but no action is going to be done...evern break-point

  • Can PDF files be included with a movie on iDVD?

    I'm using iMovie to create a movie of a presentation recorded by video camcorder, and that effort looks to be promising so far. When the iMovie editing is finished, I want to burn the presentation on iDVD as a digital seminar. My hope is to provide c

  • OBIEE / BI Publisher report question

    Hi, quick OBIEE / BI Publisher question. We have a requirement to produce a very formatted, complex report. All of the data exists in OBIEE - but there are multiple subject areas needed to answer the questions (thus multiple Answers queries). Assumin

  • Multiple SAP systems in MSCS Master DVD

    Hello, We are going to install a second SAP system in a MSCS cluster and following the installation guide "Installation of Multiple SAP Systems in MSCS: Oracle" I have been looking for the new installation Master CD for the Multi-SID MSCS Installatio

  • Header Repeats when table runs onto 2nd page

    I have a form with a dynamic table in which the user is allowed to add and remove rows to it as needed.  The table also has a column on the end of it that will become visible/hidden on the click of a button.  It also performs basic arithmatic (additi