Interesting but strange behavior

Somebody in this forum posted the following code
class A {
  public void show(A a) {
    System.out.print("A.show(A);\t");
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); System.out.println();
       b.show(a);    b.show(b);    b.show(bAsA); System.out.println();
    bAsA.show(a); bAsA.show(b); bAsA.show(bAsA); System.out.println();
}The output was
A.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);
All this made perfect sense except for the output of
bAsA.show(b) which was B.show(A);
This is perplexing for me as the parameter being passed i.e., b is of type B then why this output. Any real explanation would be very welcome.

I thought the person in the other forum answered this pretty well but I will try it from another angle.
Method overloading is actually nothing more than a fancy way of naming a method. The resolution to which method will be called is done at compile time exactly as if the overloaded methods were named differently.
If your example was re-written as follows:
class A {
    public void showOne(A a) {
        System.out.print("A.showOne(A);\t");
class B extends A{
    public void showOne(A a) {
        System.out.print("B.showOne(A);\t");
    public void showTwo(B a) {
        System.out.print("B.showTwo(B);\t");
B b = new B();
A bAsA = new B(b);
bAsA.showOne(b);You would expect the output to be
B.showOne(A)
This is because the compiler resolved the method call to be showOne of class A. The compiler can only look at the reference type not the actual runtime type (since it does not exist yet).
When the call is performed at runtime, the JVM knows to call the method from the actual instance which has overrided the showOne method. You would not expect the JVM to call the showTwo method because the names are different.
When you overload a method, the actual name (signature) of the method includes the parameters exactly as if you had a "named" it differently.
Somehow I think I could have said this clearer but maybe it will help anyway.

Similar Messages

  • Strange behavior - compositions being cut down

    I'm trying to create After Effects compositions to be used in my Premiere Pro projects, but strange behavior is making this completely impossible. Here's how it goes:
    1. Start a new AE project, start a new composition.
    2. Add clips/effects/etc., save.
    3. Start a NEW AE project, start a NEW composition.
    4. Add clips/effects/etc., save.
    5. Composition 1 has now been cut down to the time composition 2 and when trying to open composition 1 in AE, it redirects me to composition 2.
    I don't get what's going on... it's like they're being linked, but they're two entirely different projects/compositions. This is crazy and it's wasting a lot of my time. Any help would be appreciated.

    Let me slap my self on the forehead and say "D'oh"  It's your workflow. You're using dynamic link in Premiere Pro. The proper workflow is to have all of the comps in the same AE project. In Premiere Pro you go to File>Dynamic Link>New After Effects Project. You create your comp size in Premiere Pro, not in AE, then AE opens up and you create your comp. When you want to create a new dynamic link you follow the same procedure.
    Dynamic link can only look at one instance of AE at a time so it's looking at the last project for the comp info. It can't find comp 1 in project 1 because it's only looking at project 3. That explains the same comp showing up in all three locations. Fix the workflow and you'll fix the problem. In fact, I think that if you open up project 3 and import project 1 and project 2, then same project 3, then open up Premiere Pro your problem will be fixed.

  • Strange behavior in deleting images - works on second but not first try

    In Library mode, Grid view, right after importing, after I select several images with an "x" to be deleted, when I bring up the "Delete Rejected Photos" dialog, I find this strange behavior. I get the message that there are not photos marked for deletion. I then invoke the dialog again, and my photos that were marked show up, with the choices of deleting from disk or removing from the catalog. What am I likely doing wrong? I'm on WinXP Pro with LR 2.2. Thanks!
    Dilip

    Dilip,
    I too have seen this behaviour in all versions of LR. Even when deleting a single image in the develop module. If LR is writting the preview you can't delete the file until the preview is rendered. I think it's more to do with the OS not allowing the deletion of a file being accessed than a LR bug as such.
    Gordon

  • Strange behavior of entourage with shared IMAP folders

    Hi the list,
    I have a strange behavior with entourage 11.2.5 with shared IMAP folders. Here's what I'd like to do :
    All this has to do with spamassassin and spamtrainer. Some of our mails accounts are IMAP ones, but most are POP only and I don't want them to be IMAP. But I also want both IMAP and POP users to have some IMAP access to shared mailboxes for spam and ham to be learned. For those who are using IMAP accounts, that's not a problem with shared mailboxes. But, considering those with only POP accounts, I decided to create a dedicated user called anti_spam, using IMAP access, with two mail boxes that are spam and non_spam, so that all POP users could share this account.
    Using SirAdmin, I set l/p/i ACL rights for anyone and the same for anti-spam user so that mail can't be read back with this shared account. Everything just works fine with Mail, but it doesn't work with Entourage. I set up an IMAP account for anti_spam to get an access to shared mailboxes even if main account is a POP one. Everything's fine except I can't write anything on mailboxes : I get an error 1025 and a denied access for writing. The only way to get write access to these mailboxes is to add "r" ACL to them with SirAdmin, which is NOT the solution as it would allow anybody to read mails. It's obvious it has more to do with Entourage than OS X mail service, all the more trying the same conf in Thunderbird is OK as expected.
    I was just wondering if somebody here would have some idea of what could be wrong ...

    I'd be interested to hear if anyone has a solution too as am having the same problem of not being able to write to IMAP mailboxes.
    JJJ

  • Strange behaviors

    I was in the Finder going through my files trying to free up some disk space and some strange behaviors happened. As I go through the media files (video clips, flash files, etc.) they automatically play even though I did NOT hit the space bar to invoke Quicklook option and it happens to all of the files in that folder. Now I wasn't bothered by that, just thought it was strange however what I found interesting is as all of these happening is the Apple Menu Bar is disappear but as I move the mouse up top it reappear as if it has a hide menu bar and unhide the menu bar as I hover over with the mouse. Does that mean that it is possible to do a hide/unhide menu bar option? Never seen that before, does anyone else experience this?

    Welcome to Apple Discussions.
    8lias wrote:
    Does that mean that it is possible to do a hide/unhide menu bar option?
    No, it only means you are able to do it because there is some corruption either in your Home folder or in the system. Let's find out:
    Create a new account, name it "test" and see how your apps work in that User acct? (That will tell if your problem is systemwide or limited to your User acct.) This account is just for test, do nothing further with it.
    Open System Preferences >> Accounts >> "+" make it an admin account.
    If the problem is present in the test account also, then it is systemwide. In this case try repairing this with the 10.5.2 Combo Update This is a fuller install, as opposed to an incremental "delta" update so it should overwrite any files that are damaged or missing. It does not matter if you have applied it before.
    (Note: If you are running build 9C7010 do not install the Update.)
    Remember to Verify Disk before update and repair permissions after update from /Applications/Utilities/Disk Utility.
    If the problem does not appear in the test account try starting in "Safe Mode" (It will take a bit more time to startup because it runs a directory check first).
    If that works go to System Preferences >> Accounts >> Login Items and remove them. Boot normally and test. If there are still problems, go to ~(yourHome)/Library/Contextual Menu Items and move whatever is there to the desktop. Then do the same with /Library/Contextual Menu Items. Lastly, try moving /Users/Home)/Library/Fonts to your desktop and restarting.
    Log out/in or restart, if that sorts it start putting items back one at a time until you find the culprit.
    Let us know.
    -mj

  • Strange Behavior with gMSA in Server 2012 R2

    Greetings,
    I have been doing some testing with gMSA Accounts in a Server 2012 R2 environment (two separate environments, actually), and I have noticed something very strange that occurred in both environments, which does not appear to be occurring in one of our customer's
    self-managed environments.
    We created a Group Managed Service Account using the following article:
    http://blogs.technet.com/b/askpfeplat/archive/2012/12/17/windows-server-2012-group-managed-service-accounts.aspx
    Everything went smoothly, and the account installs/tests successfully on both of the hosts that we are testing on. I am able to set my services to run under the account, and most of them appear to work fine. I am having some issues with a few of my services,
    and I believe that the strange behavior I am seeing may have something to do with this - described below: 
    As soon as I set the service's Log On Account (via the Log On Tab under the Service's Properties), the entirety of the "Log On" tab changes to "greyed out," and I am unable to change the Log On account back via the GUI (Screenshot
    attached).
    I found that I am able to successfully change the account via Command Line using sc.exe, but the Log On tab remains greyed out! So far, I have found nothing to remedy this, but confirmed that it happens for any service I set to use the gMSA as the Logon
    Account, and that it happens in 2 separate test environments, but not in a Customer's production environment - very strange.
    All servers in this environment are running Server 2012 R2, and domain Functional Level is currently Server 2012.
    I have been unable to find any information online about this behavior, so I am hoping someone has seen this before, and can explain why this is happening.
    Nick

    VIvian,
    Yes, we used the Install-AdServiceAccount gMSA command on each host using the gMSA account, and then ran Test-AdServiceAccount gMSA, which returned "True."
    However, one thing I noticed is that if I run Test-ADServiceAccount gMSA as a Local Administrator, it fails with the following:
    PS C:\Users\Administrator> Test-AdServiceAccount gMSA$
    Test-AdServiceAccount : The server has rejected the client credentials.
    At line:1 char:1
    + Test-AdServiceAccount gMSA$
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : SecurityError: (:) [Test-ADServiceAccount], AuthenticationException
        + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.Security.Authentication.AuthenticationException,Microsoft.A
       ctiveDirectory.Management.Commands.TestADServiceAccount
    If I run Test-ADServiceAccount gMSA as Domain Administrator, it returns true:
    PS C:\Users\Administrator.<domainname>> Test-AdServiceAccount gMSA$
    True
    Is this normal?
    Overall, I think the issue I am running into is at the Application Level, and not a problem with the gMSA, as it appears to be working. (Can Start/Stop services without any issues). I will be investigating my issue further with 3rd-party vendors, unless
    you think there is something wrong with my gMSA accounts based on the information I have provided.
    Nick

  • Strange Behavior from iTunes 7.2

    Running itunes - 7.2Recently had my itunes library “corrupted” or non functional.
    Spent a long, long time rebuilding the library (see below) and noticed some strange behavior that has me terrified that itunes is corrupted and I am going to loose all the hard work, etc..
    1. I have about 100 GB of music in various formats (apple protected/itunes store, mp3 (128 to 320), apple lossless, wav) and when I tried to rebuild the library by clicking on add to library it only added about 65 GB of the 100 GB. I had to go through and figure out what was missing and manually choose the specific folder when I added it.
    Major pain and very time consuming.
    So it is not adding songs correctly, but through way too much effort able to work around this.
    2. About ½ of the itunes store tunes I purchased are no longer apple protected format. Somehow they were converted to mp3 at 192kbs. Some of the songs play fine others are now not as crisp and make a poping sound or skip. How could this happen? Are these files corrupted? Will I loose them?
    3. At the top center of itunes the information bar, where the read out is for what song is playing and how much time has elapsed in the song, is not working. When I click on a song it starts playing but the elapsed time bar and counter never move, and when the next song starts playing the information never changes. It is stuck on what ever song you initiate play with by clicking on it and the information stays frozen.
    4. itunes randomly stops playing at the end of a song….If listening to an album it is usually after three or four songs and when listening to a play list it is usually after one song.
    I am afraid itunes is corrupted and will not function correctly and I am going to loose the hard work I put in trying to recover from the last crash.
    Any suggestions??
    Can’t wait for time machine. I hope it works as advertised. If so I could just go back in time to the last time iTunes worked correctly and go from there.

    First of all I hope that you have a good b/u of all your tunes - either on ext HD or on DVD. Don't forget to b/u the iTunes Library and .xml files at the same time.
    Have you tried to reinstall iTunes? Drag the app to the trash and remove the iTunesX.pkg from HD>Library>Receipts>iTunesX.pkg. Using a fresh .dmg of iTunes 7.2 reinstall.
    Have you repaired permissions with Disk Utility?
    Is your Quicktime up to date? At least version v7.1.5.
    MJ

  • Has anyone experienced this strange behavior when selecting a region of an image in preview?

    When I select a section of an image that has the height and/or width of one pixel, the bounding box does the strange thing pictured to the left (at around 6x mag).  The box starts out the correct dimension on that axis (i.e., 1 px), but tapers down to 0 px by the other end of that line.  Below is an example (at 80x) if a 1 x 2 px box.  Depending on the direction you sweep the mouse when selecting the box can also appear as a single diagonal, horizontal, or vertical line.
    Copying and pasting the selection demonstrates that this does not have an effect on the shape of the selection, only on how it is displayed.
    I don't suppose that this is anything but a curious little bug with no impact on performance, though it could be confusing to some small subset of users.

    Interesting but I do not see this in my Preview/cropping.
    see the annotation:

  • Strange behavior when I try to match a mpeg2 video with the menu size image

    hello all,
    got a strange behavior when I try to match a mpeg2 video with the menu size image,
    menu size is 1920 x 1080 (photoshop file)
    mpeg2 video 1920 x 1080 (1second 19 frames)
    the idea is to go from the menu link to the next sub menu with a video as transition, using the same image on the video as the menu and then zooming in (in my case through a door) to end up after the zoom in the next level menu.
    I try to achieve a smooth change from the first play menu picture to the video image into the next level menu picture,
    everything works good but when I watch it on the preview mode on the left and right side of the video it shows a black bar at least 15 to 25 pixel wide, that means the video image appears smaller and it causes a little jump what is preety disturbing and can not be sold as a professional work.
    why encore treats the video size and picture differently?
    it's gratful appreciated if somebody who got experience in a transition I mentioned obove posting any solution,
    thankl you all

    Hi all
    I'm having a very similar problem with Encore. My menu items are distorting (a minor but infuriating squashing top and bottom) when previewed.
    Using Encore,PS,AE CS4
    DVD format SD PAL DV widescreen
    I created 3 menu frameworks and 3 video transistions to link them in AE. On the final frame of each transistion in AE I saved the frame with Composition>Save Frame to> Photoshop Layers. In PS i added the button functionality and saved.
    In Encore I use Dynamic link to import AE transistions as timelines and imported each PS menu twice, once as "menu" and once as an asset.
    When I link the timeline transistions to the menu and preview at the point the menu begins the whole image is squashed. When the next transistion is activated the image returns to its original size.
    Thinking it was the use of PS that was causing the menus to distort I used the menu asset directly in the time line. Obviously no menu functionality but also no distortion. The AE transistion flowed straight into the "menu" just as I expected.
    In the properties panel the menu Aspect Ratio 16:9
    The AE transistions PAR is SD PALwidescreen 1.4587.
    I did try the Blu Ray suggestion above but the same distortion was apparent.
    Any suggestions short of squashing the video to match the menu would be welcomed.
    Thanks

  • Strange behavior of textareas in BPEL Worklist (10.1.2)

    I have a very strange behavior with linebreaks in all my <textarea>s in the BPEL-Worklist-jsps: (they work fine as <INPUT>s
    Example:
    Default-text:
    line1
    I update the textarea to:
    line1
    line2
    -> hit update
    line1
    *** (second line is completly missing)
    -> hitting update again (no change in text)
    line2line1
    *** (all on one line with the new line in front)
    As Value I use:
    <%=PayloadFormGenerator.selectNodeValue(payload, "/ns0:task/ns0:payload/ns1:abstract", form.getNamespaceMap(),"string", context.getLocale())%>
    and as mentioned: It works fine for <INPUT>.
    What do I do wrong? Is this a bug?
    Daniel
    Message was edited by:
    user552073

    Had the same problem, could not get it to be consistent. I would say this is a bug, but decided to edit payloads via the database in the end...

  • Strange behavior with Zoom and Image control

    HELP - I have a strange behavior (bug?) with using Zoom
    effect on an Image that has been placed on a Canvas. I am using
    dynamically instantiated images which are placed on a canvas inside
    a panel. I then assign a Zoom IN and Zoom Out behavior to the
    image, triggered by ROLL_OVER and ROLL_OUT effect triggers. THE BUG
    is that the image jumps around on the Zoom OUT and lands on a
    random place on the canvas instead of coming back to the original
    spot. This is especially true if the mouse goes in and out of the
    image very quickly. HELP -- what am I doing wrong? Computer = Mac
    OS X 10.4.9 Flex 2.0.1
    Here's a simple demo of the bug -- be sure to move the mouse
    in and out rapidly:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="setUp();">
    <mx:Script><![CDATA[
    import mx.events.EffectEvent;
    import mx.effects.Fade;
    import mx.effects.Zoom;
    import mx.rpc.events.ResultEvent;
    import flash.display.Sprite;
    import mx.core.UIComponent;
    import mx.controls.Image;
    private var zoomIn:Zoom;
    private var zoomOut:Zoom;
    private function setUp():void {
    var image:Image = new Image();
    image.id = "album_1_1";
    image.x = 200;
    image.y = 200;
    image.width = 64;
    image.height = 64;
    image.source = "
    http://s3.amazonaws.com/davidmccallie/album-128.jpg";
    image.addEventListener(MouseEvent.ROLL_OVER, doZoom);
    image.addEventListener(MouseEvent.ROLL_OUT, doZoom);
    myCanvas.addChild(image);
    zoomIn = new Zoom();
    zoomIn.zoomHeightTo = 2.0;
    zoomIn.zoomWidthTo = 2.0;
    zoomIn.captureRollEvents = true;
    zoomIn.suspendBackgroundProcessing = true;
    zoomOut = new Zoom();
    zoomOut.zoomHeightTo = 1.0;
    zoomOut.zoomWidthTo = 1.0;
    zoomOut.captureRollEvents = true;
    zoomOut.suspendBackgroundProcessing = true;
    private function doZoom(event:MouseEvent):void {
    var image:Image = Image(event.currentTarget);
    if (event.type == MouseEvent.ROLL_OVER) {
    zoomIn.target = event.currentTarget;
    zoomIn.play();
    } else if (event.type == MouseEvent.ROLL_OUT) {
    zoomOut.target = event.currentTarget;
    zoomOut.play();
    ]]>
    </mx:Script>
    <mx:Panel width="100%" height="100%"
    layout="absolute">
    <mx:Canvas id="myCanvas" width="100%" height="100%">
    </mx:Canvas>
    </mx:Panel>
    </mx:Application>

    There must be bugs in the Zoom effect code -- I changed the
    Zoom to Resize in the above code, and it works perfectly. Of
    course, Resize is not as nice as Zoom because you can't set the
    resize to be around the center of the image, but at least it works.
    Does anyone know about bugs in the Zoom effect?

  • Strange behavior of "Partial message encryption "  in OWSM

    Strange behavior of “Partial message encryption “  in OWSM
    If message format is like this
    <cban:transferFund xmlns:cban="http://cbank.com">
    <cban:arg0>string</cban:arg0>   
    <cban:arg1>string</cban:arg1>   
    </cban:transferFund>
    Then body element configuration in message encryption setting
    Name space  http://cbank.com
    Element arg0
    is working fine
    But my requirement is for below message
    <cban:transferFund xmlns:cban="http://cbank.com"> <!--Optional:-->    <
    <arg0>string</arg0>   
    <arg1>string</arg1 >
    </cban:transferFund>
    For this
    Name space : http://cbank.com
    Element : I tried all possible combination but none is working
    I tried these
    :arg0
    //:arg0
    //cban:arg0
    //cban//arg0
    cban:arg0
    With Regards
    Siddharth

    Had the same problem, could not get it to be consistent. I would say this is a bug, but decided to edit payloads via the database in the end...

  • Strange behavior after using NIK plug-ins

    Every once in a while I encounter this strange behavior of Aperture. I first process the NEF's in Aperture (white balance, Exposure, Enhance... and, when needed, Cropping) and then I fine tune the image with the NIK plug-ins; when needed DfIne 2.0, Viveza, Color Efex Pro 3.0 and Sharpener Pro 3.0 Output Sharpener.
    If I look at the processed picture then, I get a perfect presentation of the photo;
    !http://users.skynet.be/fc419085/Aperture-1.jpg!
    But when I press Z to zoom into a 100% preview I get this;
    !http://users.skynet.be/fc419085/Aperture-2.jpg!
    When I select the Loup in the normal view mode I get this;
    !http://users.skynet.be/fc419085/Aperture-3.jpg!
    This doesn't happen with all my pictures, yesterday I processed a series of 8 pictures an 6 of them showed this behavior the other two acted normal and I can't see what I did differently whit these last two.
    When I export the strangely behaving photo's to a Tiff or a Jpeg, I get perfectly normal pictures.
    The original NEF behaves normal. I have seen this behavior with NEF's from a Nikon D200, D2x and a D300. I have Aperture 2.1.2 running on a 2.33 GHz Intel Core Duo MacBook Pro running Mac OS X 10.5.6
    Does anybody know what's happening and if so, how to solve this problem?
    Cheers,
    Ivan

    I did some testing and what I found is too weird to be true.
    First this mashed up look doesn't only happen after using NIK plug-ins, it also happens when making a roundtrip to Photoshop, given that certain conditions are met.
    Give it a try yourself. Crop an image to an uneven pixelcount dimension, for example 4227 x 2797 and make a roundtrip to Photoshop. Then have a 100% view look at the new image in Aperture. You'll have a mashed up view, at least I do.
    Now crop the same original image to an even pixelcount dimension, for example 4228 x 2798 and make an roundtrip to Photoshop once more. When you have a 100% view of the new image now, you'll see a perfectly normal photo.
    Do you think Aperture developers are reading this forum?

  • Strange behavior from a PB G4 (Part 2)

    On to my next issue. Often when I'm typing the insertion point will jump to someplace other than where it should be or just disappear all together. I'm not doing anything to cause it to do this. I've been being really carefull to not to do anything wrong. I'ts often enough to be a real nuisance. It happened 7 times during my first post (Strange behavior from a PB G4) and 3 times during this one. Please help. Thanks.

    Igor_G5 wrote:
    ... I thought about putting in a larger drive but when I looked up instructions for it i was surprized at how difficult it was.
    Did you use the iFixit website? It has excellent pictures and instructions that are easy to follow.
    Replacing any hard disk drive will be challenging for a paraplegic, but with someone's help it can be done fairly inexpensively. There are many tiny fasteners that require tiny tools. Use an egg carton to store them, separated by their location in the PowerBook.
    Earlier PowerBooks are easier to work on than later ones.
    I still use a PowerBook G4 on occasion, mostly for importing video for editing in iMovie. I upgraded its original 60 GB HD to a much larger one. If you were to do this you would need to locate the PowerBook's original System Install DVD to install and subsequently update OS X and all its original programs.
    If you ensure at least a few gigabytes free space, I think most of your problems will be fixed. When free disk space gets down to a few hundred megabytes or less, performance will suffer dramatically. You don't want it to ever get anywhere near that low. Strange things start to happen.
    Keep the number of icons on the Desktop to a minimum also. That makes a difference, for reasons that I do not fully understand.

  • I get a strange behavior of the tab bar and of the location bar in Firefox 29.0 for Mac.

    I have just installed Firefox 29.0 for Mac.
    I get a strange behavior of the tab bar and of the location bar with this new version.
    Instead of the location bar, I get two rows of symbols. And it's impossible to write anything in the location bar.
    (I'd like to add a screenshot, but I cannot find a way to do it.)

    Thank you for your tip.
    I found the culprit: it was an extension called RSS Icon 1.0.6.
    I removed it and now Firefox 29.0 is working perfectly.
    Now I'll have to find a replacement for that extension.
    Thank you once again. Your tip was essential.

Maybe you are looking for