Another Inheritance Question, please help.

Below is a setup of two packages and three classes:
package com.foo.package1
* This is the main superclass.
public class SuperClass extends Object {
    public SuperClass () {
    protected getFoo() {
        return "foo";
}here is the second package:
package com.foo.package2
import com.foo.package1.SuperClass;
* This class extends SuperClass. Obviously, I removed
* all methods for brevity.
public class SubClass extends SuperClass {
    public SubClass () {
        super();
* This class extends SubClass. A method here is supposed to
* create an instance of the SuperClass and call a method on it.
* In this case, {SuperClass#getFoo()} is called.
public class SubSubClass extends SubClass {
    public SubSubClass () {
        super();
    public void method() {
        SubClass sc = new SubClass();
        System.out.println (
                sc.getFoo());
}Now why do I get a compile exception "getFoo() has protected access in com.foo.package1.SuperClass"? Should that be the case?
Thanks in advance.
Georg.

It isn't a bug. Saying that protected members of a class are accessible from subclasses is not exactly true.
From the JLS: 6.6.2 Details on protected Access
A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object.
SubSubClass is not responsible for the implementation of SuperClass. So basically, a class can only have access to protected members defined in a superclass if either:
a) it is in the same package
- or -
b) the type of the reference used to access those members is that class, or one of it's subclasses.

Similar Messages

  • Another battery Question - Please help!

    Ok, this is probably going to be a dumb question, but I might as well ask it...On the 30GB Video iPod- it says up to 14 hours of play, when it comes to battery life. Now obviously, I think that means, if you leave your iPod on and not turn it off, it will last 14 hours as far as playing music is concerned, right? I only ask because I use my iPod at the gym and what I do is play music from one playlist, have the backlight set at 2 sec., EQ is off and then play the music on the playlist for 1.5 hours until my workout is done. Then, the next day, I do the same thing. I've noticed that over 5 days, playing my iPod while I work out for 1.5 hours per workout, the battery lasts for about 9 hours total. Does that sound about right? Basically, I'm wondering if my battery is defective or not. Should it last 14 hours total before it needs to be re-charged?

    Well, I do go by the meter, but actually, when the meter is in "red," it lasts me about 2+ hours. When the iPod completely dies, as in music stops playing - I try to restart it, but nothing happens, so I guess my iPod at that time truly does "die out" as far as battery life is concerned...
    But I guess what I was originally asking is this: the first time I charged my iPod, I charged for 5 hours. Then, I took it to the gym, played a playlist for 1.5 hours and then turned it off for the night...I did this same routine for 5 straight days. Then, after 9 hours of total play, *i.e., 1.5 hours x 5 days/5 workouts = 9 total hours before the battery died. Is this normal? Or am I suppose to get more life out of my battery?
    Thanks again for your help!

  • I do forgot my Apple ID security question, please help me how to rescue email address or how to reset Apple ID security questions?

    I do forgot my Apple ID security question, please help me how to rescue email address or how to reset Apple ID security questions?

    From another post:
    On your browser, whether Safari, Google Chrome or otherwise, navigate tohttps://appleid.apple.com.
    Once here click Manage your Apple ID button and sign into your iCloud account. Here, on the left side select Password and Security and this will list options on the right side. You should be able to see an option to reset your security questions.
    Note other links in realtion to rescue email address:http://support.apple.com/kb/HT5312
    If you cannot see or reset your security question, or even obtaining an error, then you would have to contact Apple directly: http://support.apple.com/kb/HE57. Here you would explain the issue, transfer you to an Account Security Agent who will be able to veritfy your identity and assist you in the resetting of you security questions.

  • Hey. i just restored my iphone and now it says your apple id is disabled then i forgot everything about my email and security questions please help me enable my apple id

    hey. i just restored my iphone and now it says your apple id is disabled then i forgot everything about my email and security questions please help me enable my apple id
    i dont think there is another way to unlock my apple but i need to

    Hello there, Th3FoX98.
    The following Knowledge Base article is a great resource for what to do if you've forgotten the answers to your Apple ID security questions:
    If you forgot the answers to your Apple ID security questions
    http://support.apple.com/kb/HT6170
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • I want to bring over music from my iTunes library on iMac to an ipod touch with another apple id. please help

    I want to bring over music from my iTunes library on iMac to an ipod touch with another apple id. please help. Is this possible. In former versions of itunes this was posible. I can't find the solution is iTunes 11

    Perhaps those apps require a newer version of iOS than is compatible with your iPod.

  • HT2968 I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    Hi AlphaCentori,
    If you are having issues accessing the Apple ID that was used to originally purchase those apps, you may find the following article helpful:
    Apple Support: Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/ht5312
    Regards,
    - Brenden

  • I want to change my apple id password but I forgot the security questions please help me some using my icloud I'd

    I want to change my apple id password but I forgot the security questions please help me some using my icloud I'd and if confirmation is must so please phone number is mine please send a code please help me my apple

    Welcome to the Apple community.
    If you are unable to remember your password, security questions, don’t have access to your rescue address or are unable to reset your password for whatever reason, your only option is to contact AppleCare, upon speaking to an operator you should explain that your problem is related to your Apple ID, this way you will not be charged for assistance, even if you don’t have an AppleCare plan.
    The operator will take you through some steps you may have already tried, however they need to be sure they have exhausted all usual approaches before trying to reset your account, so you should try to be helpful and show patience with the procedure.
    The operator will need to verify they are speaking to the account holder and may ask you some questions that only the account holder could know, and you will need to answer them if the process is to proceed.
    Once the operator has verified your identity they will send a message through to your device which contains an alpha numeric code, which you will need to read back to them.
    Once this has been completed they will send an email to your iCloud email address after a period of 24 hours, so you should check that mail is enabled in your devices iCloud settings.
    Upon receipt of the email, use the reset link provided to reset your password, after which you should be able to make the adjustments to iCloud that you wish to do.

  • My apple id have been blocked an i do not remember the identity or security question please help what can i do?

    my apple id have been blocked an i do not remember the identity or security question please help what can i do?

    If your account is disabled you might be able to re-enable it via this page : http://appleid.apple.com, then 'reset your password'
    You might then need to log out of your account on your iPhone and iPad by tapping on your id in Settings > iTunes & App Storeand then log back in so as to 'refresh' the account on it.
    For your security questions, if you have a rescue email address (which is not the same thing as an alternate email address) on your account then the steps half-way down this page will give you a reset link on your account : http://support.apple.com/kb/HT5312
    If you don't have a rescue email address then 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 (you can also try this link if you can't get your account enabled via the above)
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down the HT5312 link above to add a rescue email address for potential future use

  • Hi, I have traveled the country and have forgotten my security questions please help me thank you

    Hi, I have traveled the country and have forgotten my security questions please help me thank you

    Call Apple to help reset your Security Question.
    http://support.apple.com/kb/HT5699

  • HT201303 I forgotten my answer of security questions, please help me. Thank you !

    I forgotten my answer of security questions, please help me. Thank you !

    You need to ask Apple to reset your security questions; as described in this article, it can be done in Vietnam by phoning 1-201-0288 and then 800-708-5413.
    (107433)

  • HT201363 Hello, I have my pass word, I have my Apple ID, but itunes think I am buying a song for the first time and is asking me 2 security questions, please help, what should i do?

    I cannot remember the answeres to my security questions, please help.

    You need to ask Apple to reset your security questions; this can be done by phoning AppleCare and asking for the Account Security team, or clicking here and picking a method, or if your country isn't listed in either article, filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (105959)

  • I want to change my security question in my apple accnt. but the problem is, there is no Link shown that i could reset or change my security questions. please help!!

    i want to change my security question in my apple account. but the problem is, there is no Link shown that i could reset or change my security questions. please help!!

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    (117399)

  • I was hacked i kept getting emails that some purshcaes were being made when no one was downloading them and i guess they hacked my apple iD because they changed the security question and now i cant change anything without the security question please help

    I was hacked i kept getting emails that some purshcaes were being made when no one was downloading them and i guess they hacked my apple iD because they changed the security question and now i cant change anything without the security question please help i want to reset the security question but i cant.

    You should contact Apple by phone as soon as possible. You'll need to change your Apple ID and all passwords.
    See Contact Apple at the bottom right of this page.
    Hope this helps.

  • HT5312 i forgot my secret question, please help me this problem. Thanks

    I forgot my secret question, please help me this problem. Thanks

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    And/or see the  More Like This  section on the right.

  • Hi I live in Iran and I forgot the answer to the security question please help me thanks

    Hi I live in Iran and I forgot the answer to the security question please help me thanks

    How to reset your Apple ID security questions.
    Go to appleid.apple.com, click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. (If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email)
    Go to the Password & Security section on the left side, and click on the link underneath the security questions that says 'Forgot your answers? Send reset security info email to [email]'.
    This will generate an automated e-mail that will allow you to reset your security questions.
    If that doesn't work, or  there is no rescue email link available, then click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later.
    Next, go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.
    Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.

Maybe you are looking for

  • How to Turn My PowerBook Titanium into an iPod on Steriods!!!!?????

    Might sound weird.... but I bought my PBG4 Titanium when it was first released as a must have product... I don't really use it for much other than storage space and showing potential customers some of my web work... I leave all my productivity work t

  • Spotlight not searching recent iPhoto titles

    I upgraded to iphoto 06 and imported some photos. I gave them all their own appropriate names in the title bar. Closed iphoto. No problem. Opened iphoto again, it crashed right away. And again right away. Opened iphoto later and imported some more ph

  • Calling SQL Server Script File in Hypersonic DB

    HI All, I am using Hypersonic Database with java swing. To update the database, i am getting SQL Server script file through a webservice. The problem is i dont have any idea, how i can update Hypersonic Database with the SQL Server script file. Pleas

  • Menu Bar for Struts application

    Hi All, We are developing the Struts based Web Application using Hibernate and for this we need the Menu Bar for all the pages in the application.But we are unable to write the code for the menu bar using java classes. If possible please send the cod

  • SAP netWeaver 7.0 SR3 安装问题2 请教高手

    安装到第28步,弹出一个错误,如下: err: ERROR 2008-12-25 17:20:02.218 FCO-00011  The step start with step key |NW_Onehost|ind|ind|ind|ind|0|0|NW_Onehost_System|ind|ind|ind|ind|2|0|NW_CI_Instance|ind|ind|ind|ind|11|0|NW_CI_Instance_Start|ind|ind|ind|ind|1|0|start was