How does interface inheritance work ??

I have the following code. The printout is
Main
w
x
w
I don't understand how this is working. Clearly interface inheritance is working differently than normal class inheritance. Please explain.
thanks in advance.
kris.
The code follows
interface C
     char w = DD.echo ('w');
     char x = DD.echo ('x');
interface D extends C
     char y = DD.echo('y');
     char z = DD.echo('z');
     char a = DD.echo(w);
class DD implements D
     static char echo(char c)
          System.out.print(c + "\n");
          return c;
     public static void main (String args[])
          System.out.println("Main");
          DD dd = new DD();
          System.out.println(w + "\n");
}

The interface only needs loaded if one of its members
is accessed (although this is probably implemented
differently on different JVMs).No.
The interface is loaded.
It is not initialized. There is a difference. See section 12 of the JLS.
Assuming the above is true, it appears the following
is happening
1. C is loaded because w is accessed from DD�s main .
This loading causes �w� to be echoed and then �x� to
be echoed since loading the interface initializes the
members which in turn call the echo method (I am
assuming that this only happends when the members are
not �constants�).
2. The main method then echoes the w variable (which
is �w�).
Having said this, I would think this code would behave
differently on different JVMs so I am not sure how it
could even be a �good� theoretical question (unless
this is documented in the JLS).It is in the JLS.
Also, loading the the interface may not really be what
is happening; the initialization code may be in-lined
in the class (this could be tested by printing w twice
in main � really strange behaviour).No. It can't inline the initilization of one class in another class.

Similar Messages

  • How does role inheritance work in GRC

    Hi All,
    We are implementing GRC PC 10.0 where we have activated Role inheritance for organization in Maintain Authorization Customization Node in SPRO.
    What i understood is by activating the role inheritance for organizations, you can specify that authorizations are to be passed on to lower levels of the organization. However I need to know if inheritance also helps in picking up the recipients while doing planning activity, I have two queries in this regard:
    For eg :
    1) if we have a Control Tester role maintained at subprocess and control level both and if a User is assigned to subprocess for Control tester role then in that case User will be also be mapped to all the control beneath the subprocess for Control tester role due to inheritance concept ..correct? and while planning for that particular control, does user maintained at subprocess level will be picked as a recipient ?
    2) A Control tester gets mapped at the subprocess level. This means that all controls under that subprocess would show this tester as inherited from the subprocess. However, if we do not want the inherited tester to perform the test, and instead map a tester at the control level, the inherited tester still appears. IN this case, will only the tester mapped at the control level receive the work inbox item for the control test (as this overrides the inherited tester), or will the inherited tester also receive it?
    Regards,
    Shikha

    The interface only needs loaded if one of its members
    is accessed (although this is probably implemented
    differently on different JVMs).No.
    The interface is loaded.
    It is not initialized. There is a difference. See section 12 of the JLS.
    Assuming the above is true, it appears the following
    is happening
    1. C is loaded because w is accessed from DD�s main .
    This loading causes �w� to be echoed and then �x� to
    be echoed since loading the interface initializes the
    members which in turn call the echo method (I am
    assuming that this only happends when the members are
    not �constants�).
    2. The main method then echoes the w variable (which
    is �w�).
    Having said this, I would think this code would behave
    differently on different JVMs so I am not sure how it
    could even be a �good� theoretical question (unless
    this is documented in the JLS).It is in the JLS.
    Also, loading the the interface may not really be what
    is happening; the initialization code may be in-lined
    in the class (this could be tested by printing w twice
    in main � really strange behaviour).No. It can't inline the initilization of one class in another class.

  • How does interfaces overcome the problem of single inheritance?

    1) How does interfaces overcome the problem of single inheritance? Can anyone give an example of how it works?
    2) In a Java book, I read: "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
    Why does different classes require to implement a Java class library?
    Can anyone please enlighten? Thanks.

    >
    2) In a Java book, I read: "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
    Hi, let me try to explain this.
    Say you have a left hand drive BMW and a right hand drive AUDI. typeOfDrive is a property for these two cars. If i am trying to make this property abstract, i will prefer to put this property in an Interface called Car. My classes BmwCar and AudiCar implement the Car Interface; by which they can use the property typeOfDrive.
    So, the behaviour 'typeOfDrive'; when expected to be implemented by Disparate entities BmwCar and AudiCar, we try to abstract that property to a common Interface called Car.
    interface Car {
    String typeOfDrive;
    String getTypeOfDrive();
    class BmwCar implements Car {
    String getTypeOfDrive() {
       return typeOfDrive;
    void setTypeOfDrive(String tod) {
    this.typeOfDrive = tod;
    class AudiCar implements Car {
    String getTypeOfDrive() {
       return typeOfDrive;
    void setTypeOfDrive(String tod) {
    this.typeOfDrive = tod;
    }Now, when you create instance of your disparate classes, you will define the declared property 'typeOfDrive', as 'Left Hand Drive' for BmwCar and 'Right Hand Drive' for AudiCar.
    So, "Interfaces are implemented and used throughout the Java class library when behavior is expected to be implemented by a number of disparate classes."
    You can refer to many web wikis for better examples and explanations.
    Regards,
    ~N~

  • How do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the onli

    how do you connect your photoshop elements on your computer to your account online? and how do you create a customized url? how does the gallery work and how do you access it? i have trouble signing in on my program from my computer to connect to the online photoshop, and I really want to create my own customized url and post photos to my gallery and share them with the world, family, and friends, but i need help because i can't figure how to do any of this, would really appreciate feedback and assistance, thanks, - claire conlon

    To add to sig's reply, "calibrating" does not calibrate Lithiu-Ion batteries, it calibrates the charge reporting circuitry.  If you look at the effect of deep discharging Lithium-Ion batteries in the data from the independent test group, Battery University, you will see that doing so shortens the life of the battery significantly. It looks like an optimum balance between use and life is at a discharge level of 50%.

  • How does TimeOut(Sec) works/ behave in FTP Adapter?

    Hi ,
    How does TimeOut(Sec) works/ behave in FTP Adapter?
    Lets Say : If I mention 300 Secs in this . How Should it behave ??
    if a file processing in adapter is taking more then 300 sec , will it also be  terminated ??? what error response i will get in such case.
    Regards
    Prabhat Sharma.

    Hi,
    if there's a network error the channel may hang (for a very long time)
    if you specify 300 secs after that time the channel will reset the connection and you can start pooling again
    for more details:
    Note 849089 - XI 3.0 / PI 7.0 File Adapter: FTP Timeout Handling
    Regards,
    Michal Krawczyk

  • How does SAPscript 'WRITE_FORM' works ?

    Hi
    I have a Z program working fine, it is a SAPM07DR copy and i aggregated some fields to WASCHEIN form.
    But i see when the program (standard or copy) calls the write form, the field values in program have other values (just the previous values) than the values wich appears in the printed form.
    For example: 
    WASCHEIN KOPF Window has the WERKS value:
             Plant:    &*T001W-WERKS&
    But when the write form is called
              CALL FUNCTION 'WRITE_FORM'
                EXPORTING ELEMENT = 'KOPF'
                WINDOW            = 'KOPF'.
    In the program the *T001W-WERKS field has a different value that the value wich appears in the spool, debugging i see that the field has the prevoius value in the program:
    Program
    *T001W-WERKS
    (when Write Form).............Spool
        '     '...................................Plant:  0900
        '0900'.............................Plant:  0901
    I had to do the same logic in my new aggregated fields, but i realy don't know why does the program works in this way.
    Why the print program and sapscript function works in this way ?
    How does WRITE-FORM works, that is where the function take from the values to print ?
    Thanks
    Frank

    Hi Max
    I hope the program works like you said, but it works:
    old_werks = '   '
    T001W-WERKS = '0900'.
    *T001W-WERKS = T001W-WERKS .
    *T001W-WERKS = old_werks.    <-- '   '
    CALL FUNCTION 'WRITE_FORM'
    (form KOPF with *T001W-WERKS)
    old_werks = '0900'
    T001W-WERKS = '0901'.
    *T001W-WERKS = T001W-WERKS .
    *T001W-WERKS = old_werks.    <--  '0900'
    CALL FUNCTION 'WRITE_FORM' 
    (form with *T001W-WERKS)
    But the FM prints 0900 and after 0901, when the *T001W-WERKS values were '    '  and  '0900'   !!!
    (and with the *T001W-NAME1 field occurs in the same way)
    Why does the FM prints that values ??
    Thanks
    Frank

  • How does Merged Dimensions Work in WebI created on SAP BI Queries

    Hi,
    I need to know how does Merge dimensions work in WebI when using SAP BI Query as source?
    Below is my understanding when connection is defined for the universe on oracle database:
    1) To get the data in merged dimensions, there must be physical join (Either Direct or vai some other tables) between different tables at backend level (This means  there  must be join between tables in Oracle database.)
    2) we get the UNION of data when dimensions are merged at webI level.
    I dont know how this works in SAP BI.
    Since there is different data model defined for different BI Queries in SAP , and for each BI Query and there is seperate Universe, So how can you get correct data in WebI when there is no connections in DSO's used in different BI queries?
    Can any one suggest me the way data apperas in merged dimensions for WebI created on SAP BI?

    I assume we are only talking about merging dimensions in Web Intelligence here and not on the BW backend. this is a client side mere where you have 2 resultsets.
    if you want to do this on the BI server side it would be a multi-provider combining different InfoProviders - or a InfoSet - depending on the join type you need. MultiProvider is a union, Infoset allows you to choose
    Ingo

  • Transfer Rules: How does the mapping work?

    Transfer Rules: How does the mapping work?
    Is there a document out there that explains the following or can someone help clarify it for me. I have some confusion on what is really going on.
    When I create an InfoSource (IS_Test)  as a “Flexible update…”  and then “Assign DataSource”  (DS_Test) and I respond Yes, to the message “DataSource assignment DS_Test to InfoSource IS_Test Save”
    a) <b>Under “Transfer_Structure/Transfer_Rules”</b> in the InfoSource
    1)  the “Transfer Rules” tab, what are the fields found in the right column (Assigned InfObjct-field)? And where do the fields you enter in the left column (<b>Communication Str/</b>Transfer rules) eventually go?
    2)  the “DataSource /Trans. Structure” tab, can I always assume that all the fields in the right column (DataSource) came from DS_Test? The left column (Transfer Structure), in my test was exactly the same as on the right. Where do these fields eventually go?
    b) Under “<b>Communication_Struct.”,</b> in the InfoSource
    3. the right column (ISource Fileds) where from those InfoObjects. if I am now creating my InfoSource. Where did they come from?
    4. The left column is “<b>Communication Structure</b>”, which at this point has no InfoObjects, if I move a couple of InfoObjects from the right to the left, where do these Objects in the left eventually go?
    5. what is the relationship between the “Communication Structure” in 4 and 1? Or any relationship between a) and b) as a whole?
    Thanks.

    Hi Caud,
    As Ashish pointed out, communication structure contains fields (infoobjects) that suppose to go to data targets. Which IO in CS to which IO in the data target will go (and what transformation of data may occur) is determined in URs of the data target.
    The transfer structure is the structure in which the data is transported from the source system into BW:
    http://help.sap.com/saphelp_bw33/helpdata/en/3f/0e503c3c0d563de10000000a114084/frameset.htm
    In “Transfer_Structure/Transfer_Rules” in the IS, DataSource /Trans. Structure” tab, right part shows fields in the Datasource, the left part – fields in the transfer structure. There is also a transfer structure in R/3 for a given DS. Transfer structure in BW is created identical to the TS in R/3 during TRs activation.
    During data load data are transferred 1:1 from TS in R/3 to TS in BW.
    TS in BW corresponds to the PSA table structure.
    How data from PSA are transferred to the CS is determined in TRs.   
    The 3rd column (“Field”) (“Transfer Rules” tab, right part (Assigned InfObjct-field)), contains field names of the DS (TS); and the 1st column shows IO in the CS to which the DS field will go. So, it’s a mapping DS filed -> CS field.
    The left part (“Communication str./Transfer rules”) is always identical to the CS content. But the 4th column (“Tp”) shows possible data transformation during transfer from PSA to CS. If this column contains a yellow triangle then there is no transformation (Value of DS field will go to value of CS field). If there is a red cross, it means that no data for this CS field is supplied from a DS. You can click on this yellow triangle and choose: 1). Another field from a DS; 2). Constant; 3). ABAP routine; 4). Formula. So, here you can determine the data transformation. Moreover, there is a possibility to create a start routine (blank sheet icon at the top).
    And finally, here are the answers on your questions:
    Q:
    a)     Under “Transfer_Structure/Transfer_Rules” in the InfoSource
    1) the “Transfer Rules” tab, what are the fields found in the right column (Assigned InfObjct-field)? And where do the fields you enter in the left column (Communication Str/Transfer rules) eventually go?
    A: Right part shows a mapping between DS and CS fields. Left part shows CS fields and data transformation (TRs) during data transfer from TS (PSA) to the CS. These are fields in the CS that will go to data target and which are fed from a TS (DS).
    Q: 2) the “DataSource /Trans. Structure” tab, can I always assume that all the fields in the right column (DataSource) came from DS_Test?
    A: Yes, you are right.
    Q: The left column (Transfer Structure), in my test was exactly the same as on the right. Where do these fields eventually go?
    A: As I described, left and right parts are identical. These fields will go to CS.
    Q: b) Under “Communication_Struct.”, in the InfoSource
    3. the right column (ISource Fileds) where from those InfoObjects. if I am now creating my InfoSource. Where did they come from?
    A: these are fields from an IS template, the name of this template you can see above this right part.  Actually, during IS (CS) creation you can choose different templates and choose fields from them transferring them into the left part.
    Q: 4. The left column is “Communication Structure”, which at this point has no InfoObjects, if I move a couple of InfoObjects from the right to the left, where do these Objects in the left eventually go?
    A: these are fields of CS (left part) and as I said before they will go to data target.
    Q: 5. what is the relationship between the “Communication Structure” in 4 and 1? Or any relationship between a) and b) as a whole?
    A: CS in 4 just shows IOs that will be transferred to data target. CS in 1 also shows how values for CS IOs are to be fed and transformed.
    Best regards,
    Eugene
    Message was edited by: Eugene Khusainov

  • KPI -How does the periodicity works in SM

    Periodicity is @ Context level only? That means we have to define different contexts for weekly &monthly? That doesnu2019t fly good
    How does the periodicity works in SM..data entry as well as frontend display?

    Hi TR,
    When looking at a scorecard, you should see the status for all objectives and KPIs during the same time period. If you look at Revenue KPIs for just one week and Cost KPIs for the whole month, how can you assess how you performed in that month?
    This doesn't mean that the metrics in PAS cannot have different periodicities. They can! But when looking at data in the scorecard these periodicities will be converted to the scorecard periodicity. For example if you have monthly metrics and you are looking at scorecard data quarterly, the scorecard will show you the value for the 3 months of that quarter. Here, you should take care to define the proper time consolidation properties for the metric (it can be SUM, like in costs or revenue, AVERAGE, LAST, FIRST...).
    Likewise, if you have quarterly metrics and you want to see scorecard data monthly, then PAS does a breakdown of the value per months.
    Anyway, if you are looking to setup a weekly scorecard, that will likely include a different set of metrics that a monthly scorecard would. Weekly scorecards will problably include more operational metrics and will lack the strategic focus of scorecards with a broader time scope.
    Regards!
    Ricardo

  • How does SUM actually works

    Hi,
    I'm puzzled by how SUM actually works.
    I've got a table with the following fields:
    SET_OF_BOOKS_ID NOT NULL NUMBER(15)
    SUMMARY_CODE_COMBINATION_ID NOT NULL NUMBER(15)
    DETAIL_CODE_COMBINATION_ID NOT NULL NUMBER(15)
    TEMPLATE_ID NOT NULL NUMBER(15)
    LAST_UPDATED_BY NOT NULL NUMBER(15)
    LAST_UPDATE_DATE NOT NULL DATE
    ORDERING_VALUE NOT NULL VARCHAR2(25)
    Using the below, I was able to get the total value of all the ordering value.
    select sum(ordering_value) from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    I was happy that I could get the total value but am puzzled as ordering value is of data type VARCHAR2.
    Is sum(ordering_value) a VARCHAR2 or a NUMBER then?
    I did a simple test, inserting the following record:
    insert into gl_account_hierarchies values(1,1024,1,2,3,'11-APR-2002','xyz');
    After committing, I double check by using the following statement:
    select * from gl_account_hierarchies where last_update_date = '11-APR-2002';
    and was able to retrieve the newly inserted record.
    But when I did another check with the following statement:
    select * from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    I wasn't able to retrieve the newly inserted record.
    Why is that so? How does SUM actually works? Is the output of SUM a VARCHAR2 or NUMBERIC value?
    thanks in advance!!
    Yu S.S

    SUM() gives a number.
    What you have come across is an implicit data conversion. Basically the SQL parser doesn't reject your query as being syntactically invalid just because you're attempting a mathematical function on a non-numeric column. Instead when you execute your query SQL substitutes this
    select sum(to_number(ordering_value)) from gl_account_hierarchies where set_of_books_id = 1 and summary_code_combination_id = 1147;
    If you want to check this create a view
    create order_value as select sum(ordering_value) sum_val from gl_account_hierarchies ;
    and then desc it.
    Cheers, APC
    SUM(

  • How does request.setAttribute() works?

    How does request.setAttribute() works?
              Does it append data to http header and forward? Does it set to a memory
              space like session.setAttribute() does?
              Thank you
              Jim
              

              Q. Does it append data to http header and forward?
              No.
              Q. Does it set to a memory space like session.setAttribute() does?
              Yes. So you can set attributes in request scope and use them in the servlets and
              JSPs in the servlet chain via request dispatcher and jsp:include/jsp:forward.
              "Jim" <[email protected]> wrote:
              >How does request.setAttribute() works?
              >Does it append data to http header and forward? Does it set to a memory
              >space like session.setAttribute() does?
              >
              >Thank you
              >Jim
              >
              >
              

  • How does at NEW works?

    Hi,
    How does AT NEW works with the below code>
    LOOP AT i_crhd into x_crhd.
    at new arbpl.
    v_resource = x_crhd-arbpl.
    LOOP AT i_afko into x_afko.
    at new plnbez.
    v_matcode = x-afko-plnbez.
    READ TABLE i_mseg into x_mseg with key x_afko-aufnr.
    IF sy-subrc eq 0.
    IF x_mseg-bwart eq '101'.
    v_menge_101 = v_menge_101 + x_mseg-menge.
    ELSEIF i_mseg-bwart = '102'.
    v_menge_102 = v_menge_102 + i_mseg-menge.
    ENDIF.
    ENDIF.
    endat.
    ENDLOOP.
    endat.
    ENDLOOP.
    Thanks a lot!

    Hi,
    In your program....
    For every new arbpl AT NEW will trigger and for eveery at new plnbez one more new field will trigger.
    Ex:  We have below records in your internal table 'i_crhd'.
    arbpl
    101
    101
    102
    103
    103
    and  we have records in internal table 'i_afko '
    plnbez
    A
    A
    A
    B
    B
    C
    C
    For every change in arbpl record AT new will fire and for every cheange in plnbez one more AT new will fire.
    Pls. reward if useful...

  • I wanted to know how does technical support work via icloud and is there any new technology out that helps providing technical support

    i wanted to know how does technical support work via icloud and is there any new technology out that helps providing technical support?

    basically I’m doing a project were I wanted to find out if there are recent technology  out that provides technical support for example they do it with remote access but is they any new ways that  they can support us and just wanted to find out if icloud gives technical support then how?

  • How does chat applet works?

    how does chat applet works? What specific technologies should i learn to make a chat messaging work?
    thanks in advance for ur help...

    Chat applets work on sockets. Normally there are two parts. One server and one or more clients. The clients connect to the server and any message sent by a client is then distributed by the server to all the other clients.
    Sun's site is incredibly slow tonite so I'll give you a google link
    http://www.google.com/search?hl=en&ie=UTF-8&oe=UTF-8&q=chatserver+chatclient+java

  • How does opatch lsinventory works

    How does opatch lsinventory works ?

    Hi,
    Refer links:
    http://download.oracle.com/docs/cd/B19306_01/em.102/b16227/oui8_opatch.htm
    http://download.oracle.com/docs/cd/B16240_01/doc/em.102/e15294/prereq_checks.htm
    http://avdeo.com/2008/08/19/opatch-utility-oracle-rdbms-patching/
    thanks,
    X A H E E R

Maybe you are looking for

  • How can I bring the file size of jpegs down to ~60k?

    Hi. I like to resize my photos to 800x600, 72dpi for upload to the web. Now, my cameras are usually set to maximum resolution, which can include 180 or 300dpi, but I can find no Automator action to change the dpi. Using Preview and/or Graphic Convert

  • Problem with iDVD

    Hi, I made my movie in FCE.Then I prepared the project of the DVD in iDVD. This movie consist of 5 parts. If I play this movie it stop after each part and go back to the menu. How can I set the project to play the whole movie without stopping.

  • Inconsistent "End of file error" on "open for access "myFile.txt"

    I have a script that accesses a txt file containing info needed for values in the script. Sometimes the script works flawless, but once I get the "End of file error," it won't work right anymore unless I log out and log back in or if I dump the file

  • Error message from mail

    For the past few weeks I've been getting an error about not being able to receive mail, but I can, sometimes. Recently switched internet providers but it was happening prior to that. Any thoughts would be appreciated. Haven't changed any settings on

  • Oracle Replication update conflict handler creating notifications

    Hi All, I want to use an update conflict handler that overwrites the records in the destination database, while notifying the dba about the conflict by creating a log entry to a log file (alert log or other custom log file). I know that I can use pre