What the Concept behind this

hello friends plz check this code
class a
class b extends a
class c extends b
class test
     public void print(a first)
          System.out.println("Here in A");
          System.out.println(first);
     public void print(b first)
          System.out.println("Here in B");
          System.out.println(first);
public class kr
     public static void main(String arg[])
          test t=new test();
          b obj =new c();
          System.out.println(obj);
          t.print(obj) ;
this will print Here in B
if change b obj = new c to a obj = new c
this will print Here in A
what's the concepts behind this
help me thanks
Vivek Nidhi

I saw this a while back:public class A {
public void show(A a) {
System.out.print("A.show(A);\t");
public class B extends A{
public void show(A a) {
System.out.print("B.show(A);\t");
public void show(B a) {
System.out.print("B.show(B);\t");
public class ABTest {
public static void main(String[] args) {
A a = new A();
B b = new B();
A bAsA = new B();
a.show(a);    a.show(b);    a.show(bAsA);
bAsA); System.out.println();
b.show(a);    b.show(b);    b.show(bAsA);
bAsA); System.out.println();
bAsA.show(a); bAsA.show(b); bAsA.show(bAsA);
A); System.out.println();
}You had to guess what the output was.
Almost everybody saidA.show(A);   A.show(A);   A.show(A);  
B.show(A);   B.show(B);   B.show(B);  
B.show(A);   B.show(B);   B.show(B);   when in fact, the correct answer isA.show(A);   A.show(A);   A.show(A);  
B.show(A);   B.show(B);   B.show(A);  
B.show(A);   B.show(A);   B.show(A);   the reason is that although B overrides A.show(A)
which is taken account for at runtime - giving the B.
on the last row - the decision of whether to call
show(A) or show(B) is made at compile time, so
the last column says show(A) - the parameter is of
compiletime type A even if it's runtime type is B -
and the last row is show(A) for similar reasons.
I hope this helps (and makes sense)
Well it makes sense to me but what is really surprising is the result of
bAsA.show(b);
which comes out to be
B.show(A);
while parameter being passed in the method is b which is of type B. Could anybody explain that?

Similar Messages

  • What is the concept behind MASTER_IDOC_DISTRIBUTE

    What is the concept behind MASTER_IDOC_DISTRIBUTE ?

    Hi Manjunath,
    Please check the Documentation of the Function Module in SE37
    This function module is the interface from the application to the ALE layer on the outbound side. The application can pass an IDoc, the so-called master IDoc, as an internal table using the parameters MASTER_IDOC_CONTROL and MASTER_IDOC_DATA.
    This IDoc is then converted into one or communcation IDocs and stored in the ALE layer. IDocs for which no errors occurred are passed to dispatch control.
    In the table parameter  COMMUNICATION_IDOC_CONTROL the header records for the communication IDocs created are retturned. You can tell whether processing was successful from the field STATUS.
    A COMMIT WORK must be dispatched in the calling program, otherwise the IDocs may not be dispatched.
    Best regards,
    raam

  • What is the concept behind using table PA0002 and structure p0002.

    Hi,
    What is the concept behind using table PA0002 and structure p0002.
    Many times, I have seen Looping at structure e.g. p0002, p0006 etc. and data is processed and also seen Looping at table PA0002, PA0006 etc. with further appropriate subtypes if any to retrieve a value and process the same.
    In which context tables like PA,HRP,IT etc. are used and structures p0001,p0002 etc. are used.
    Regards,
    Ameet

    HI,
    As mentioned  that that Structure Pnnnn is user as a internal tablw when a LDB is used.
    Ex.
    TABLES: PERNR.
    INFOTYPES: 0001.
      GET PERNR.
        PROVIDE * FROM P0001 BETWEEN PN-BEGDA AND PN-ENDDA.
        WRITE:  / P0001-PERNR,
                  P0001-STELL,
                  P0001-BEGDA,
                  P0001-ENDDA.
        ENDPROVIDE.
    Here it is important to declare the infotypes you want to read  and so the system will create internal tables  ex. P0001.
    Tables PA0001 are database table with following fields
    MANDT
    .INCLUDE  PAKEY
    .INCLUDE  PSHD1
    .INCLUDE   PS nnnn
    Thanks,
    Poonam.

  • Pending Licenses : What is the concept behind pending licenses ?

    hi,
    I am seeing pending licenses in device license in call manager 8.5.1
    a) How can i filter devices whose licenses are pending.
    b) What is the concept behind pending licenses.

    Thanx [email protected]
       By gettign total no. of pending DLU's = some units apart form total alloted DLU's , consumed units and free units.
       What i understand is
        total alloted DLUS's =  total consumed DLU  + total free DLU + Pending DLU's.
       thus one pending licenseis as good as consuming a  license ?
       M i thinking in correct direction,if yes how can i free these pending DLU's .

  • Points and discussion about the concepts behind making a 2D game

    Hi all. I'm currently trying my hand at a 2D RPG style game. I have a few questions open for discussion, however, regarding the general points of implementation behind it.
    1. Tiles vs static background argument aside, am I right in the thinking the best way of implementing movement across a big background map is actually to move the background and other sprites in relation to the player, giving the illusion of player movement although he in fact never moves from the center of the screen? Is there a way of actually creating a large map, populating it with sprites, and then moving the player across it and panning the screen after him?
    2. Collision detection. If we go with the idea of moving everything in relation to the player rather than the player himself, woudln't this mean a large amount of calculations when collision detection occurs. Example, u want the player to stop moving when he hits a brick wall so you have to tell every entity sprite to stop moving in response to key presses (because remember, pressing up moves everything else up, not the player character).
    3. Isometric. Is the easiest way of implementing an isometric style game just to develop isometric graphics and sprites?
    4. Tiles. I've been doing a lot of reading into tiles but I'm not sure what's a better implementation: a tile system which consists of the entire background and things like houses split into tiles or a simple big background which can be scrolled around and is populated by house sprites which are all moved in relation to the player and their collision detections done individually. Tiles certainly seem like a nice innovation but I feel like the graphics suffer as a consequence and u end up with a 8bit NES looking game!
    I'm just getting to grips with the concepts behind a lot of game design and all of this are some interesting points which I thought would be insightful to discuss. Opinions please!
    Cheers.

    Everything I'm about to say is based off of a tile-based Maze game I made.
    1. Using a big background map is a bit lazy if you ask me, but graphically it would be easier to create a nice-looking game. You also have to think about memory. Let's say you manage to get an 800x600 background image at the size of 200kb with JPEG compression. That 200kb jpg image you use as a background is not 200kb when loaded into memory. I dont remember exactly how much bigger it gets in memory, so this next statement is probably wrong. But I heard that: 4bytes per pixel for the ARGB data, and there are 800x600 (480,000) pixels. That's 480000*4 (1920000) bytes if that statement is right. But it's probably wrong, so hopefully Abuse or someone will correct it :)
    2. Move EVERYTHING up? I think you're a little mixed up. When the background (and all objects with it) is scrolled, their actual X,Y data is not changed. It is simply drawn according to the scroll offset. The only thing that is being calclulated for movement is the character/scroll offset. Think of it as a camera. The entire world is not moving, just the location of where you're viewing it. Quick example:
    You have a Tree who's location is (10,10). If the scroll offset is (0,0), then that Tree will be drawn at (10,10). But let's say your character moves up 5 pixels. You say you want him centered, so the scroll offset also moves up 5 pixels, making the offset (0,-5). When it's time to draw again, that Tree can't be at the same place it was, because the character moved. If the character moved up, the Tree would appear as if it moved DOWN. So you'd draw it like:
    g.drawImage(tree.getImage(),tree.x-scrollOffsetX,tree.y-scrollOffsetY,null);With that math, the Tree is actually drawn at (10,15), which is lower than before the character moved. You don't actually loop through all of your objects and change each and every X and Y value, you just change the global scroll offset
    Speaking of collision detection, this is where TileMaps have a large advantage. In a TileMap, you don't have to check through each and every object in the world for collision. You can just grab the 4 surrounding tiles (north,west,east,south) from the Tile array. This means there are only 4 collision detections no matter where the character is in any situation on the map.
    If you used an image for background instead of tiles, you'd have to check each object in the world for collision because it's harder to tell how close it is to the character. One thing you could do is just grab all of the object currently visible on screen and check their collision, but, depending on where you are on the map, this could easily cause an inconsistent frame rate (you could be in a field of grass that has no collision or a forest of 50 trees each screen- LOTS of collision!).
    3. I dont got much to say about isometric :P
    4. an 8bit NES game, eh? That is the common misconception that you have to use images that are the same size of the tiles. Have you seen the game "The Legend of Zelda: Four Swords"? That's a tile-based game, but on several occasions you see trees that are 10 times bigger than the 20x20 tiles. They mixed it up, they used a TileMap for the basic ground, and put good looking large images on top. The large images (such as a large tree) uses 4 or 5 "base" tiles that are used for collision. That way the character will only collide with the bottom-half of the tree, giving the appearance of going "behind" the tree when the Y value is above the middle line of the tree. This is far away from looking like an 8bit NES game :)
    I hope that was more helpful than it was confusing, but I tend to babble, so.. anyway. Hope it helps :o

  • When exporting a photo to photo library, all EXIF data is lost. What rational is behind this?

    When exporting a photo to photo library, all EXIF data is lost.
    What rational is behind this?

    Thanks for your reply on this!
    One issue seems to be with Foto Library app itself. When running an auto-correct there it looks like EXIF will be stripped more or less completely.
    Second issue is in iPhoto app on iOS when working on RAW. When exporting to the roll the EXIF is modified in a way. It was keeping most of the EXIF in case of Canon 5D MKII that I tested today, but the EXIF data is definately changed, e.g. lens type is different because maybe some fields are ignored there. Also the images are silently scaled down by 50% which is kind of annoying.
    The initial problem was observed with a Pentax K7 and I will need to reproduce the issue in this config I assume. Maybe tomorrow I can do this.

  • Hi Apple Community. I have a iPhone 4S . The phone works perfect, besides when to swipe to unlock to home screen. It takes 1-4 swipes. Whats the reason behind it?

    Hi Apple Community. I have a iPhone 4S . The phone works perfect, besides when to swipe to unlock to home screen. It takes 1-4 swipes. Whats the reason behind it?

    Ghubash wrote:
    My iphone 4s haven't facetime?
    This is an unrelated issue... Please start your own thread.

  • My iphone 4 suddenly blank, i thought it is out of battery and put on a charger, but in few minutes later my iphone turns to be too hot on the right half side of its body. i pull off the charger. whats the problem is this?

    my iphone 4 suddenly blank, i thought it is out of battery and put on a charger, but in few minutes later my iphone turns to be too hot on the right half side of its body. i pull off the charger. whats the problem is this?
    the next day i tried to connet with itunes on pc, but its undetectable. what should i do? i think i will need to delete notes, pivtures and video recordec by the iphone itself but how to do this since the phone cant be on at all. lease help me. its only 7moths old since i buy it

    i try to reset but nothing happened. & my warranty had end bcause i bought thru small dealer with a month's shop warranty only. due to problem of getting hot of the iphone's right side body, is it may cause of battery problem? how much will it cost to solve/repair this kind of problem?
    thank you for ur help earlier

  • Outlook 2007 doesn't show icloud service running.  Does anyone know what the dll for this service is so it can be manually added to outlook?

    Outlook 2007 doesn't show the icloud service running in Windows 7 within outlook.  Does anyone know what the dll for this service is so it can be manually added to outlook?   I've installed the icloud control panel app and set it up to synch everything, but after initially downloading my icloud calendar, it won't process any calendar updates (new entries made on either iphone 4 on ios 5 or outlook). 
    So since the control panel installed, but the service doesn't show running in outlooks "trust center" add-ins list, anyone know the actual dll file it would point to so I can see if I can add it the hard way?

    I had the same issue and figured it out.  First you have to start Outook as administrator.  To do this, shift and right-click on outlook and click run as administrator.  Next you need to enable Hard-disabled add-ins:
    Hard-Disabled Add-Ins
    Hard disabling can occur when an add-in causes the application to close unexpectedly. It might also occur on your development computer if you stop the debugger while the Startup event handler in your add-in is executing.
    To re-enable an add-in
    In the application, click the File tab. 
    Click the ApplicationName Options button.
    In the categories pane, click Add-ins.
    In the details pane, verify that the add-in appears in the Disabled Application Add-ins list.  The Name column specifies the name of the assembly, and the Location column specifies the full path of the application manifest.
    In the Manage box, click Disabled Items, and then click Go.
    Select the add-in and click Enable.
    Click Close.
    Then you need to activate it. 
    To re-enable an add-in
    In the application, click the File tab.
    Click the ApplicationName Options button.
    In the categories pane, click Add-ins.
    In the details pane, verify that the add-in appears in the Inactive Application Add-ins list.  The Name column specifies the name of the assembly, and the Location column specifies the full path of the application manifest.
    In the Manage box, click COM Add-ins, and then click Go.
    In the COM Add-Ins dialog box, select the check box next to the disabled add-in.
    Click OK.

  • What the answer for this  error on a Macintosh system, the application can not open because "NameRegistryLib" could not be found

    what the answer for this error, the application could not open because the "NameRegistryLib" could not be found

    http://www.everymac.com/mac-answers/mac-os-9-classic-support-faq/run-macos-9-on- intel-macs.html
    http://www.macwindows.com/Emulator-for-Mac-OS-9-in-OS-X-updated-for-Mountain-Lio n.html
    http://hints.macworld.com/article.php?story=20060509180914879
    How to run Classic (pre OS X) apps on Intel Macs  

  • HT204003 if i open passbook on iphone 5, it always say cannot connect to itunes, any fix from apple tech support? and whats the reason for this problem? why do we have to figure it out and not even apple can give answer??

    if i open passbook on iphone 5, it always say cannot connect to itunes, any fix from apple tech support? and whats the reason for this problem? why do we have to figure it out and not even apple can give answer??

    actually i found out how to fix it
    1 sign out of apple account
    2 close down passbook app
    3 change year to 2013
    4 reopen passbook and sign in at the button with your apple ID
    5 change the time to auto update and it should work from now on.
    this worked for me let me know if it work for you:)

  • Whats the cause of this problem

    Hi everyone!
    Whats the cause of this sort of errors/warnings in alert log.
    kcrrsarc: (WARN) Failed to find ARCH for message (message:0x1)
    tkcrrpa: (WARN) Failed initial attempt to send ARCH message (message:0x1)
    Maximum redo generation record size = 80896 bytes
    Maximum redo generation change vector size = 77472 bytes
    tkcrrsarc: (WARN) Failed to find ARCH for message (message:0x10)
    tkcrrpa: (WARN) Failed initial attempt to send ARCH message (message:0x10)
    *** 2011-04-16 01:24:12.184
    Warning: log write time 990ms, size 3KBThanks.

    The value was 10 and I just increased it to 12That seems to be an extremely high value. I would guess that your I/O system f or the redo log and archivelogs cannot keep up with the rate of redo generation.
    You may have addressed a symptom, not a cause.
    Is the cause :
    a. Very (unnecessarily) high redo rates ?
    b. Slow I/O (with a warning about log write time being logged) ?
    Hemant K Chitale

  • What does the class CL_EXITHANDLER do ? What the significance of this class

    what does the class CL_EXITHANDLER do ? What the significance of this class,

    Peters,
    Welcome to SDN!
    you can see this class in SE24 and than choose GET INSTENCE method DB on it. than put break-point on
    CALL METHODcl_exithandler=>get_class_name_by_interface
    finally run any t-code you will come into debugger mode and if you see in exit_name value after pressing F6 you will get BADi name of this perticuler T-code.
    basically we use this class for findings BADi.
    Amit.

  • HT4436 I don't see the point of having to create another email account - could someone explain the thinking behind this please?

    For iCloud syncing there are a few items that require a new iCoud email address to be created (eg. Notes and email), whilst the majority of other options do not require this.
    My question is simply why do these items need yet another email address to be created?  I would have though the Apple Id would have been sufficient to hang everything together...
    If someone could explain the thinking behind this please I will hopefully be more comfortable with it and probably more likely to start using these features!
    Thanks in advance!
    Stuart

    If TCP port 25 isn't open, then SMTP services won't work.  That's the port that all SMTP servers use to communicate amongst themselves.    (Sure, you can change the port your SMTP server is listening on, but you'd also have to change the port processing on all of the other SMTP servers around — and if you did manage to implement that change everywhere, the local network folks would likely just block the new port for the same reasons they blocked the old port.)
    If you have a public static IP address and have correct forward and reverse translations — host domain to IP address, and IP address to host domain name — then you don't need and very likely don't want to run your own DNS server. 
    More to help you learn how these pieces fit together and not something I'd expect you would need given you have a public static IP and public DNS here is a detailed DNS server configuration article for OS X Server; enable Show All Records and it applies to Server.app on 10.7 and later.  If you have questions after reading that, I can certainly answer them and also update the article to try to reduce the confusion or answer the question.
    Your host didn't have valid reverse DNS, so you'll want to get that cleared up, and you'll want to get the port blocks cleared, or work with the local network folks to set up a relay through one of the existing mail servers.

  • I use an ipad4, it keeps getting stuck randomly and i have to power it off and switch it on again. whats the solution to this problem?

    i use an ipad4, it keeps getting stuck randomly and i have to power it off and switch it on again. whats the solution to this problem?

    (A) Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.
    (B) Reset all settings
    Settings>General>Reset>Reset all settings
    Note: Data will not be affected but settings will be reset.

Maybe you are looking for

  • K9N Neo-F and AMD Athlon X2 AM2 6000+ (125W)

    Hi Everyone! I want to upgrade my PC, now I have: MSI K9N Neo-F motherboard S/N: 601-7260-010K0609058577 MS-7260 ver. 1.0 K9N Neo nForce 550, AMD AM2 CPU: AMD Athlon X2 AM2 3800+ RAM: GoodRam 2x512MB (667) and 2x1GB (667) GPU: Zotac GF 8800GT Now I w

  • How do I get my MacBook Air w OS X Yosemite to read 2.5" floppy disks from my 512?

    Legacy people help!!!! I have a Mac Book Air with OS X Yosemite and an external floppy disc drive but I can't get the MacBook to read any of my old disks--not even the program disks! How do I get it to read these disks (They were originated on a Mac

  • SCHANNEL Fatal Alert:80 in Event Viewer

    See a post in 2012 that tweaks the registry to set the alert to O thus eliminating the alert but it doesn't explain why it happens or whats causing it. On my machine it didn't start til Windows did the last .NET update leading me to believe that this

  • Annual Leave Form

    Hi, I have an annual form which i would like for it to calculate the working days between two dates. I have an error when i select the start date to be e.g. Thursday 31 October and end date Monday 4th Nov it only seems to caluculate 1 weekend day? I

  • How to time stretch a picture frame (not video) that I have panned and zoomed in Premiere Elements 11?

    Previously used Premiere elements 11 and could zoom in on a picture frame, but also Time stretch it, so the zoom would be slow.  Cannot figure out how to do this in Premiere elements 11.  When I have applied the zoom, but go to right click on the pic