Isn't this a typo error?

http://java.sun.com/docs/books/tutorial/java/IandI/override.html
Here's some code that's been posted on here before:
public class Animal {
    public static void testClassMethod() {
        System.out.println("The class method in Animal.");
    public void testInstanceMethod() {
        System.out.println("The instance method in Animal.");
public class Cat extends Animal {
    public static void testClassMethod() {
        System.out.println("The class method in Cat.");
    public void testInstanceMethod() {
        System.out.println("The instance method in Cat.");
    public static void main(String[] args) {
        Cat myCat = new Cat();
        Animal myAnimal = myCat;
        Animal.testClassMethod();
        myAnimal.testInstanceMethod();
}Based on what that lesson was trying to teach shouldn't the line
Animal.testClassMethod();be written as
myAnimal.testClassMethod();???

I didn't ignore this thread, just took a rest as it was late for me, sorry. Thx for the replies. However, what you've replied I've no problem in understanding. I get the point that instances of a class belong to an object whereas members of a class belong to the class. It's just that I thought the author of that lesson meant the line
Animal.testClassMethod();to be
myAnimal.testClassMethod();My reasoning was the topic of the lesson itself, "Overriding and Hiding Methods". An important point of that lesson is the following:
The distinction between hiding and overriding has important implications. The version of the overridden method that gets invoked is the one in the subclass. The version of the hidden method that gets invoked depends on whether it is invoked from the superclass or the subclass. Let's look at an example that contains two classes.As a reader at this point I'm thinking the author is going to demonstrate the above quote with the following two classes
public class Animal {
    public static void testClassMethod() {
        System.out.println("The class method in Animal.");
    public void testInstanceMethod() {
        System.out.println("The instance method in Animal.");
public class Cat extends Animal {
    public static void testClassMethod() {
        System.out.println("The class method in Cat.");
    public void testInstanceMethod() {
        System.out.println("The instance method in Cat.");
    public static void main(String[] args) {
        Cat myCat = new Cat();
        Animal myAnimal = myCat;
        Animal.testClassMethod();
        myAnimal.testInstanceMethod();
}Well, how does the line "Animal.testClassMethod();" demonstrate the above quote? It doesn't. It simply makes a direct call to a static method using its full name. It has nothing at all to do with objects, so yes, if you remove the other three lines in main() this one still works. Now if you change that line to "myAnimal.testClassMethod();" it still calls the static method from the superclass! But why? Afterall "myAnimal" holds a reference to a Cat! And so the line from the above quote,
The version of the hidden method that gets invoked depends on whether it is invoked from the superclass or the subclass.rings in my mind. So, overall I'm thinking there's a typo here and that the author meant "myAnimal.testClassMethod();". Well? I'm just being curious.

Similar Messages

  • Isn't this Trigger code error prone?

    Version: 10g Release 2
    I have come across a Trigger code where the :NEW pseudo variable is being assigned value like
    SELECT emp_oid into :new.emp_oid FROM emp_dtls WHERE EMP_NO =:NEW.EMP_OID;Apparently, the code is working fine. But isn't this error prone?

    It is not very useful to post this single line. One doesn't even know on which table this trigger fires, nor the relationship with the affected table and the emp_dtls table, nor whether an exception handler was programmed.
    (Probably not).
    If my assumption is correct no exception handler was programmed, this would have resulted in kick-ass time, as the code may result in either the NO_DATA_FOUND exception or the TOO_MANY_ROWS exception.
    Anyone writing that kind of code needs to be escorted to the door of unemployment immediately.
    BTW will anything bad happen if you post a question consisting of more than 1 line. Salary substracted? Fingers chopped off by your boss?
    Sybrand Bakker
    Senior Oracle DBA

  • HT5312 I forget my answer of two security questions, there is a typo error in rescue email address. How to resolve this so that I can use my Apple ID for online shopping?

    I forget my answer of two security questions, there is a typo error in rescue email address. How to resolve this so that I can use my Apple ID for online shopping?

    You won't be able to change your rescue email address until you can answer your questions, you will need to contact Support in your country to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down the HT5312 page that you posted from to correct your rescue email address for potential future use

  • HT3523 hello, this is the error I get when I try to play a video QuickTime Player can't open "solea-antonio-walter.mov" because a required codec isn't available. Any idea what I need to do? thank you

    Hello,
    This is the error message I get when I try to watcha burnt dvd, can anyone tell me what I need to do?
    thank you
    QuickTime Player can't open "solea-antonio-walter.mov" because a required codec isn't available.

    Quicktime X is a great little piece of software. However, Quicktime X is very finicky on which codec/file format it can decode/play.
    Luckily, there are DOZENS of alternative video/media players and extensions available for the Mac. Some of them are even FREE. Some of the better FREE ones include...
    PERIAN (quicktime extension)
    http://www.macupdate.com/app/mac/22923/perian
    QUICKTIME 7.6.6
    http://support.apple.com/kb/DL923
    VLC Media Player
    http://www.macupdate.com/app/mac/5758/vlc-media-player
    NICEPLAYER
    http://www.macupdate.com/app/mac/15136/niceplayer
    ... And if none of those work, there is a possibility that, that video file may be corrupted.

  • Problem in primary key column where user does typo error.

    Hi all,
    I have a primary key in the table that some part of it was the current date. For example if today date is 3rd May then it will contain xxxxxx-0503 (where xxxxxx will be unique for this day). In order save time needed to enter the data, I achieve this by having another (non database) item in the datablock where the user type the xxxxxx part and use a pre-insert trigger to add the '-0503' part to the actual primary key item in the datablock.
    This works well if the user enter the xxxxxx part in the non database item correctly. But the problem show up when the users have typo error in the non database item that break the uniqueness of the primary key. Form as usual will tell us that it cannot insert the item but when I try to fix the error, it will report that records has been inserted before. The only solution is to clear form and retype the xxxxxx part.
    Anyone have any idea on what is the best method to implement this in form? Thanks in advance for your help.

    Marcel,
    I cannot reproduce this in version 10.1.2.2. We did not "fix" this, although changes in the runtime might have fixed this "silently". I suggest you upgrade to 10.1.2.2 and see whether you still get the error.
    Steven Davelaar,
    JHeadstart Team.

  • Geotagging - how can I edit new places that I have previously created but with typos, errors etc?  How do I delete a place I have set up?

    Geotagging - how can I edit new places that I have previously created but with typos, errors etc?  How do I delete a place I have set up?  Then I could create a new, correct entry.  I'm using iPhoto '09.

    Is it OK to reply to my own question?? Thanks to the related posts that appeared AFTER I'd made the post above, I learnt about the 'Manage my places' item under the Windows menu. I felt a bit dumb not knowing this.
    BUT it doesn't completely resolve the issue.  The info shown in the EXIF (using opt-cmd-I) under Places has the place name I choose, but it is followed by a few other lines that are incorrect and do not seem to be anything to do with any data I can see under 'Manage my places'.
    Can anyone explain where these other entries might come from, and how to edit them?

  • Please help me resolve this JSP compilation error

    Hi,
    We have deployed our web app in Sun one web server 7.0 running on Sun os, and with JRE 5.0.
    Until recently, every thing was running fine, but since a few days, I am unable to get a JSP file compiled.
    This file, has a <%@include file= .. > to another file, and both these used to work fine earlier.
    This is the error message I am getting:
    <!-- org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:604)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:344)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:464)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:358)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:917)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:792)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:472)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:353)
    at com.bt.bmsnet.shared.BMSServletBase.forward(BMSServletBase.java:126)
    at com.bt.gma.web.AccountServlet.actionUpdateAccount(AccountServlet.java:2704)
    at com.bt.gma.web.AccountServlet.doGet(AccountServlet.java:5049)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:796)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:917)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:277)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:255)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:586)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:556)
    at com.sun.webserver.connector.nsapi.NSAPIProcessor.service(NSAPIProcessor.java:160)
    Caused by: java.io.IOException: tmpFile.renameTo(classFile) failed
    at org.apache.jasper.compiler.SmapUtil$SDEInstaller.install(SmapUtil.java:208)
    at org.apache.jasper.compiler.SmapUtil.installSmap(SmapUtil.java:131)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:336)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:369)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:595)
    ... 23 more
    -->
    The line "Caused by: java.io.IOException: tmpFile.renameTo(classFile) failed" suggests that the JSP file isn't getting compiled into the corresponding servlet.
    Can some one please help?

    Yes I have done that. Simple JSP pages are compiling well. But I have about 5 jsps which call some partial jsp using
    <%@ include file="somefile.jsp" %>
    And all these files are showing this error.
    I have a feeling that this is probably due to some kind of restriction on file sizes of compiled jsps in the server. Is there any such restriction?

  • Typo error in Disk Utility (Refuso)

    Os X 10.5.8 Utility Disk...horrible typo error.
    Italian Localization.
    Same also in SNowLeopard?
    Quickpost this image to Myspace, Digg, Facebook, and others!

    In order to do a repair on a disk, you can't be booted from it. So in Lion and Mountain Lion, if you reboot holding the command and r keys down, you'll boot into recovery mode. Follow the directions to bring up Disk Utility (it will be one of the menu items on the recovery menu), choose your hard drive on the left of the window, click the first aid tab, and click repair disk on the right hand side. If it completes without error, you're all done, so reboot and you're back in business.
    If you get an error message that the drive can't be repaired, please post back with the message.

  • Made a typo error

    how do i change my screen name as i made a typo error when joining. nado-gt4 should read nado-gr4
    would it not be simple to be able to change it in my profile. i can't see anywhere to do that.
    thanks
    We all make mistakes said the Dalek climbing off the Dustbin.
    This question was solved.
    View Solution.

    Just send a PM to one of the admins and they should be able to change it for you.
    Make it easier for other people to find solutions, by marking my answer with \'Accept as Solution\' if it solves your problem.
    Click on the BLUE KUDOS button on the left to say "Thanks"
    I am an ex-HP Employee.

  • NewMacBook Power Adapter Typo Error

    There is a typo error on this link: as per 11/08/2006 10:10 PM
    http://www.apple.com/macbook/specs.html
    That said it shipped with 60W Power adapter, but if we scrool on the specs table, it said comes with 85W Power Adapter (usually for MacBook Pro).
    Hope everybody that order this new MacBook do double check so nobody will be dissapointed later.
    And if there is moderator around, do inform the webmaster to fix the typo error to the rightfull information.
    Good Luck.

    There is truly moderator around, and the typo problem now fixed: 11/09/2006 3:45PM
    http://www.apple.com/macbook/specs.html
    So the buyer will get the 60W Power adapter instead of 85 as stated before.
    Hope This Help.

  • When i try to open photoshop this shows up Please uninstall and reinstall the product.  If this problem still occurs, please contact Adobe technical support for help, and mention the error code shown at the bottom of this screen.  Error: 16

    i had to take my photoshop file into a hardrive because my dad was going to give me a new Mac and when things didn't work out and went back to my old one i use the time capsule thing to save everything before but didn't give me photoshop so i physically moved the file and tried to open it but then this error shows up
    Please uninstall and reinstall the product.
    If this problem still occurs, please contact Adobe technical support for help, and mention the error code shown at the bottom of this screen.
    Error: 16
    and when i click the uninstall app on the file it tells me this
    The alias “Uninstall Adobe Photoshop CS6 2” can’t be opened because the original item can’t be found
    and when i click fix alias i click on photoshop and the app just turns into photoshop and i just run in circles
    please help thank you

    Run the cleaner tool and reinstall.
    Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    Download CS6 products
    Mylenium

  • I've checked my current plugins and it still shows Adobe Acrobat Version 7 for Netscape (7.0.9.50) I tried to do the update but I got an error - "Please tell Microsoft about this problem" "Send Error Report/ Don't Send".

    I've checked my current plugins and it still shows Adobe Acrobat Version 7 for Netscape (7.0.9.50)
    I tried to do the update but I get the same error each time - "Please tell Microsoft about this problem" "Send Error Report/ Don't Send".
    Also, do I need to Disable or Uninstall the Extension: "SEO For Firefox 3.3.4 as this was highlighted?
    == This happened ==
    Every time Firefox opened
    == When I try to do the update

    http://www.microsoft.com/mac/support
    http://answers.microsoft.com/en-us/mac/forum/macword?auth=1
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/microsoft-wor d-for-mac-2011-will-not-open-error/ecc42616-6f49-40bb-b8f5-e21c711ea359

  • The connection to Microsoft Exchange is unavailable. Outlook must be online or connected to complete this action. Error while connecting to exchange through Outlook 2010

    Hi,
    I have set up Exchange Server 2013 on Windows Server 2008 R2. Everything is working fine except I am unable to configure Exchange account in Outlook 2010 or any other version. It says 
    "The connection to Microsoft Exchange is unavailable. Outlook must be online or connected to complete this action." 
    Error screenshot is attached. Even, I am able to configure exchange active sync on my adroid and ipad which is working perfect. Please let me know if any body have any idea about it. Searched many blog and forum but still now solution till now.
    Thanks in advance
    Regards,
    Manoj

    Hi Manoj,
    Can you ping your Exchange server? It would hlep us isolate the fault from network releated issue.
    Is there a trusted certificate installed on Exchange 2013 server?
    If you run the test of RPC over HTTP in
    https://www.testexchangeconnectivity.com/, is there any error returned?
    For more information, please refer to :
    http://technet.microsoft.com/en-us/library/bb123741(v=exchg.150).aspx
    http://social.technet.microsoft.com/Forums/en-US/exchangesvrgeneral/thread/1b4dc21c-c745-4699-8eee-423105608dcd/
    Thanks.
    Fiona Liao
    TechNet Community Support

  • I have been trying for an hour to delete all of the photos from my iphone5.  Can't do it, except for 1 at a time.  I can't even connect it to my PC and delete them from my computer.  Why isn't this easy and intuitive?

    I have been trying for an hour to delete all of the photos from my iPhone 5.  I have googled it several times and there doesn't seem to be a solution.  Have tried deleting them from my PC. One at a time deleting is impractical - I have 1000 photos!  Why isn't this easy and intuitive?

    When you hooked up to your PC did they attempt to import? Had you imported them previously and not deleted when the import was complete?
    If you have to delete them directly on your device, you need to press the select button and just keep selecting until you have all of them selected, then put them in the trash.
    You do not need to select one then trash it, then select another then trash it. You can select as many as you like before clicking on the trash icon.
    Cheers,
    GB

  • I used to update my iPhone 4S applications whenever a new update is available, but at this time, "unknown error" displays after entering my apple id password. Anyone who could help, whom they might have experienced? Thanks

    I used to update my iPhone 4S applications whenever a new update is available, but at this time, "unknown error" displays after entering my apple id password. Anyone who could help, whom they might have experienced? Thanks

    Hi Christianjr,
    When you say you reset your network settings, what do you mean, exactly?
    I saw another post on this issue, and the poster indicated that they resolved the problem by turning off their cellular date option and wifi options in Settings, and then turned them back on.
    Also, resetting your phone may help - press the Home and Power buttons at the same time and continue to hold both down until the Silver Apple appears. Once it is back up, click on the update option and see if it fixes the problem.
    If none of those things work, then need to have details on what you did to reset your network settings....
    Cheers,
    GB

Maybe you are looking for