What Exactly is Happening in this Program???

Hello All,
Here is a Program,
package myDemo;
public class MyOverRidingDemo {
     public MyOverRidingDemo() {
          super();
          // TODO Auto-generated constructor stub
          A obj=new B();
          obj.add();
          System.out.println("Value Of I : "+obj.i);
     * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          new MyOverRidingDemo();
class A {
     int i=10;
     public void add(){
          System.out.println("Add() in Class A");
class B extends A {
     int i=20;
     public void add(){
          System.out.println("Add() in Class B");
When i run this program, the out put is as follows :
Add() in Class B
Value Of I : 10
It is pretty clear that B is overriding the add() method of Class A.
When an instance of B is made and assigned to a variable of type A,
obj.add() should refer to add of B
and obj.i should refer to i of B.
but over here..why is it Referring to i Of A???

Because both classes have their own copy of int i.
Remove it from the subclass and make the add method change it somehow and you'll see the difference.
And of course the obj.i refers to A's i value since property access isn't dynamic and obj's type is A, not B.

Similar Messages

  • What exactly is happening on this on-day-shop on Friday 23rd? Will some products be reduced in price? Could someone please explain what exactly is happening?

    someone please tell me whats happening on 23rd This Month
    thanks

    All Apple has said. is:
    http://store.apple.com/us/browse/holiday/shopping_event?aid=aic-aos-naus-holiday -november2013-homepage-bf-teaser

  • What exactly is happening in the code mentioned?????

    Hi all,
    I want to know the working of the below code:
    The below code is the WHEN_BUTTON_PRESSED Trigger for the ENTER_QUERY (Push Button):
    DECLARE
      IT_ID1 ITEM;
      IT_ID2 ITEM;
      IT_ID3 ITEM;
    BEGIN
      IT_ID1 := FIND_ITEM('BUTTON.EN_QUERY');
      IT_ID2 := FIND_ITEM('BUTTON.CA_QUERY');
      IT_ID3 := FIND_ITEM('BUTTON.EX_QUERY');
      SET_ITEM_PROPERTY(IT_ID3,ENABLED,PROPERTY_TRUE);
      if :system.mode<>'ENTER-QUERY' THEN
       set_item_property (it_id1,label,'CANCEL QUERY');
       GO_BLOCK(GET_APPLICATION_PROPERTY(CURRENT_FORM_NAME));
       CLEAR_BLOCK(NO_VALIDATE);
       ENTER_QUERY;
      set_item_property (it_id1,label,'ENTER QUERY');
      ELSE
      EXIT_FORM;
      END IF;
    END;
    Can You please tell me what exactly is happening in the above code?
    I want to know the working of it. Help me plz.
    Thank You.
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    Oracle Forms 6i.

    what does if :system.mode<>'ENTER-QUERY' THEN mean??
    SYSTEM.MODE indicates whether the form is in Normal, Enter Query, or Fetch Processing mode. The value is always a character string.
    and what does GO_BLOCK(GET_APPLICATION_PROPERTY(CURRENT_FORM_NAME)); do?
    GET_APPLICATION_PROPERTY Returns information about the current Oracle Forms application. CURRENT_FORM_NAME Returns the name of the current form as indicated by the form module Name property.
    GO_BLOCK navigates to an indicated block. If the target block is non-enterable, an error occurs.
    As per the code, After i press the button, the label ENTER QUERY should become CANCEL QUERY, (that is when system is in ENTER_QUERY mode) .
    So when in the system is in ENTER_QUERY mode, it must display CANCEL QUERY, Right??
    in your post, you also said..
    The below code is the WHEN_BUTTON_PRESSED Trigger for the ENTER_QUERY (Push Button):
    We see 3 button in your code. How can we know which one is ENTER_QUERY button. Your code says...
    ENTER_QUERY;
      set_item_property (it_id1,label,'ENTER QUERY');
    So, it says.. BUTTON.EN_QUERY label will be ENTER QUERY
    Then why the code, (if :system.mode<>'ENTER-QUERY' THEN set_item_property (it_id1,label,'CANCEL QUERY');) ?? which says if system mode is not equal to ENTER_QUERY,
    then it tells to display CANCEL QUERY.
    it says.. BUTTON.EN_QUERY label will be CANCEL QUERY

  • What is the uses of this programe(accelerometer)?

    what is the uses of this programe(accelerometer) in N95 original or N95 8g and from where I can get it?

    This is Rotateme, but needs to be signed.
    http://www.bysamir.fr/rotateme/
    This is the movingball which just needs to be installed (doesn't require signing).
    http://research.nokia.com/files/MovingBall_Example.sisx
    Nokia N95
    V 20.0.015
    0546553

  • What exactly is happening/​failing when "GPIB Interfaces sequential​ly verified" FAILS?

    I have an AT-GPIB/TNT+ card installed in my computer. It fails the "GPIB Interfaces sequentially verified" portion of the Wizard program. I am able to communicate (IBIC) with my instruments, so it appears that all is working well. I do have older non-compliant GPIB interfaces so the "Scan for Instruments" does not work. What exactly is failing in the Wizard and what can I do? I have windows 95.0.

    Janet,
    Typically when the installations fails the sequential verification, it is due to either a resource conflict or a device being connected to the board during the test. You can click on the failed interface to get a brief explination of what may have caused the error.
    There are instances reported using the AT-GPIB/TNT+ board and Win 98 inwhich this error was reported even though there were no problems with the board's setup. Since you are communicating properly with the board through IBIC your board is functioning properly, and I would not be concerned with the error message.
    As for your instrument, this is likely due to your instruments non-compliance to 488.2 standards. Whenever the Measurement & Automation Explorer does a "Scan for Instruments", it sends out the stri
    ng "*idn?" (which is an IEEE 488.2 identification query string) to all of the devices on the bus. If you have older, non-IEEE 488.2 compliant instruments on your GPIB, then they will not recognize this string as a valid command. This will cause "Scan for Instruments" to fail.
    Best Regards,
    Chris D

  • What'sgoing to happen to this forum??

    Now that most of Creator's functionality is available in Netbeans Visual Web Pack, what's going to happen to this forum? I imagine there's overlap between Netbeans forums and this one, but long term, are there plans to consolidate what is clearly a converging community? I'd hate to have the knowledge chain broken by confusion in the ranks...

    Java Studio Creator isn't going away. Creator and VWP serve different but overlapping communities. Each product has its own channel for providing community support. Creator has this forum and VWP uses the [email protected] alias, accessible through http://www.netbeans.org/community/index.html. To clarify the relationship between the two closely related products, see the FAQ " Should we all move to NetBeans Visual Web Pack now from Java Studio Creator?" at http://wiki.netbeans.org/wiki/view/VwpFAQShouldwemigrate

  • What is the error in this program??????

    class FindArea
    public static void main(String args[])
    float radius=7.0f;
    float area=(22/7)*(radius)*(radius);
    System.out.println(area);
    When i execute the above program i am getting output as 147.0 why it is happening???? I dont understand.....
    Actually it should come...154!!!!!!!!

    When you divide one int by another the result is "truncated" (the decimal part is
    thrown away). If you don't want this to happen you have to tell the compiler to
    treat your integer as a double (or float). This is done in the first two cases, but not
    the third.public class IntOrDouble {
        public static void main(String[] args) {
                // prints 15.0
            double answer1 = ((double)3 / 2) * 10;
            System.out.println("answer 1 = " + answer1);
                // prints 15.0
            double answer2 = (3.0 / 2) * 10;
            System.out.println("answer 2 = " + answer2);
                // prints 10.0 because 3/2 is 1
            double answer3 = (3 / 2) * 10;
            System.out.println("answer 3 = " + answer3);
    }Test: so, what will (double)(3/2)*10 print?

  • What exactly are Logical Database in Programs?

    Hi Experts,
       While digging deep into the programs, using the T-Code SE93/SE38, we come across Logical Database.
    what is the functionality and use of this Logical Database?
    Best Regards,

    Normally moderators reject unresearched questions, but this one has not been discussed much for it's security aspects.
    In the ABAP forums you will find a lot of discussions about LDB's ("LDB" is your search term).
    Please do a search and reconsider and focus your question more.
    What is it about LDB's that you would like to discuss?
    Cheers,
    Julius

  • What Exactly Is Happening During the 2?21/2014 Azure Update

    Can anyone tell me what will happen during the upcoming maintenance window on 2/21/14 for the Azure environment?

    hi,
    What is your meaning?
    Did you want to know maintenance scheduled? I suggest you could note the azure team blog via this link (
    http://blogs.msdn.com/b/windowsazure/ )
    and pay attention to the azure dashboard form
    http://www.microsoft.com/windowsazure/status/ .
    Regards,
    Will
    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.

  • HT201077 My photos stopped going to my PC photo stream. What could have happened for this to happen?

    Photos were going to my PC photo stream & suddenly stopped around the first week of October. Don't know if this was when my iphone 4 & ipad updated to the ios-7.

    The following is from this Apple Document: iCloud: Photo Stream FAQ
    What do I need to use Photo Stream?
    To use Photo Stream, including Shared Photo Streams, you need an iCloud account, compatible devices, and up-to-date software:
    iPhone, iPad, or iPod touch with iOS 6.0 or later
    Mac with OS X Mountain Lion v10.8.2 or later and iPhoto 9.4 or Aperture 3.4 or later
    PC with Windows 8, Windows 7, or Windows Vista (Service Pack 2) and the iCloud Control Panel 2.1 or later for Windows
    Apple TV (2nd generation) with Software Update 5.1 or later
    You can still use Photo Stream without Shared Photo Streams if your devices meet these requirements:
    iPhone, iPad, or iPod touch with iOS 5.1 or later
    Mac with OS X Lion v10.7.5 or later and iPhoto 9.2.2 or Aperture 3.2.3 or later
    PC with Windows 7 or Windows Vista (Service Pack 2) and the iCloud Control Panel v2.0 or later for Windows
    Apple TV (2nd generation) with Software Update 5.0 or later
    For complete iCloud setup instructions, visit How to set up iCloud.
    You need Mt. Lion in order to use Shared Photo Streams.
    OT

  • What EXACTLY is happening when a signed applet loads in a page?

    I'd like to know what happens when a signed applet is loaded in a page with the Java Plug-in. What methods are called, in which order, what happens when the user denies the applet, etc.
    Any links to resources are also welcome.
    Thanks!!

    Hi there,
    Please go thru the following links. I think they are self explanatory and does not need more elaboraion. These links expalin how the Signed Applet is loaded and how does the Class Loader and Code Verifier make it possible for the applet to work within it's security restriction.
    Here are the links:
    1.http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/rsa_how.html
    2. http://ntrg.cs.tcd.ie/undergrad/4ba2.96/group2/applets.html
    For more information about policy files you can check the following link:
    http://www.interex.org/pubcontent/enterprise/jan01/14chew.html

  • HT201274 What exactly will happened if I reset all content and settings

    I upgraded this phone from someone else's old account bc I had info in their account I needed. Now I'm restricted from doing a lot of things because they're old passwords are still in the system how can I erase there're old IDs and passwords and change them to my own without losing all my contact information?

    If you erase all content and settings it will wipe the phone and there will be nothing on it.  If you want to change Apple IDs:
    For purchases, go to Settings>Store>Apple ID, tap the ID shown, sign out, sign back in with your ID
    For iMessage, go to Settings>Messages>Receive At, tap the ID at the top, sign out, sign back in with your ID
    For FaceTime, go to Settings>FaceTime, tap the ID, sign out, sign back in with your ID
    For iCloud, go to Settings>iCloud, scroll to the bottom and tap Delete Account.  Then set up a new iCloud account on the phone with your Apple ID.
    For mail accounts, go to Settings>Mail,Contacts,Calendars, tap each account, scroll to the bottom and tap Delete Account.  Then set up your own.
    That should about do it.  Note: for app updates, if there are apps on the phone that were purchased with his ID you will need to delete these from the phone and from your iTunes library (if there) in order to not be prompted for the password for his ID.  (Apps are permanently tied to the Apple ID used to purchase them.)

  • What exactly is a "low-level exception occurred in: ImporterFastMPEG?"

    I've been importing several HDV video files (m2t files) from my Sony HDR-DR60 HDD unit into Premiere Pro CS6 on my Macbook Pro w/ Retina Display. I noticed that this error popped up for 3 files: "A low-level exception occurred in: ImporterFastMPEG (Importer)" What exactly is happening here? What does that mean? Those video files appeared with small "?" icons next to their names in the bin. I attempted to import them again, but I was either given the same error message or only the first few seconds of the file would import. For example, one file is 645MB and is a little over 3 minutes long. Now when I try to import this file, it shows as being only 19 seconds in length.
    Now here's where it gets perplexing: I took that same file and fired up my decommisioned Windows PC with an old installation of Premiere Pro CS5.5, and it imported perfectly without a problem.
    I found a very slow work-around where I converted the m2t file into an uncompressed Quicktime MOV, but I'd like to find out what the root cause is and why I'm getting this error for these few files. I've done a lot of shooting this week, and I haven't had a problem with any other files from my HDR-60.
    So, is this a Mac/Apple problem, a Premiere CS6 problem, or are those particular files just randomly weird? Google searches have not yielded anything useful which is why I'm asking here.

    You might go back to http://forums.adobe.com/community/premiere/premierepro_current
    In the block under Ask a Question enter
    low level exception
    so you may read previous discussions
    Be sure to click the See More Results at the bottom of the initial, short list

  • WHAT THE **** IS WRONG WITH THIS UPDATE TO 8.1

    At first i thought my problems were limited to CDs not importing.....NOW MY IPOD WILL NOT SYNC WITH IT. What's the point of and itunes upgrade if my BRAND NEW IPOD won't sync with it??????

    You might get better answers if you gave more specifics. What error messages are you getting? What exactly is happening?

  • This is for Exchange 2007 but can't find a place to post it. It may apply here I don't know. What exactly happens when you suspend LCR?

    OK. I searched out here and found things close to what I need: how to suspend and restore LCR but I need another answer. I have gotten a new backup solution (Unitrends) and the Microsoft exchange write appears twice. I'm guessing one is for my first storage
    group and one is for LCR. Anyway it appears the software is trying to use the replication writer which is causing my backups to fail. Here is my question: what EXACTLY happens when I suspend the LCR (Suspend Storage Group Copy)? Does this affect regular exchange/email
    transport and receiving at all? Basically if I disable it will mail continue to flow as normal with no adverse affects? And what EXACTLY happens when I disable LCR. What if I decide I don't need it. Will disabling it affect normal email operations? Basically
    will either of these options in ANY way interfere with normal mail flow? Thanks.

    Hi,
    Based on my knowledge, suspending LCR doesn't affect the mail flow. If there is no need for LCR, you can disable LCR, and then please manually delete the LCR storage group and databaase fles.
    For more information about LCR, please refer to
    Local Continuous Replication.
    Best regards,
    Belinda
    Belinda Ma
    TechNet Community Support

Maybe you are looking for

  • Problem with iTunes hanging

    Hi all, My laptop's a few years old now and it's susceptible to overheating unless you keep the vents free and some air circulating around it. Today, I foolishly just had it sitting on my best and it overheated and turned off whilst iTunes was busy c

  • Best way to extract Item Accounting Documents

    Hi all, i need to take to BW how many documents and total amount per month from tables DFKKKO and DFKKOP (item accounting). Is there any BC structure to get this (infocubes, extractors) or any alternate consolidated table so i don't have to create Z

  • Bonjour windows prints garbage

    Hello, I have bonjour in windows xp connected to my HP psc 2410 that is attached to my Airport express. I accepted the default driver generic/pcl I get garbage printing no matter what driver I select. I am running windows xp in parallels. Thanks Fran

  • Suggestion for new M.Board

    i'm thinking of upgrade my pc to Intel Core 2 Duo E6420 Processors (2.13GHz), but totaly no idea which mainboard to choose. i was consider this two...  MSI P6N-SLI-F L775 Mothertboard  P6N Diamond (SLi ready is optional)

  • How to activate the database

    after create the database using the database configuration asistant, what the next step that we should done to activate the database. i just know that we should create the listener. other than this what should we done..pls kindly help me.im just a ne