Page 1 of 1

About Question enthuware.ocajp.i.v8.2.978 :

Posted: Thu Jul 21, 2016 10:45 pm
by christian_burger
Hello,
In this question, the correct options in the explanation were (2) and (4).
This appears incorrect or I'm missing something.
Member variable k is protected, thus available for subclasses AND within the package, so option (4) is incorrect.
Would you please comment?
Thanks,
Christian

Re: About Question enthuware.ocajp.i.v8.2.978 :

Posted: Thu Jul 21, 2016 10:56 pm
by admin
The questions asks, "which member variables are accessible from OUTSIDE the package com.enthu.qb", and option 4 says, "Member variable k, but only for subclasses.", which is correct. k is accessible from any subclass that exists anywhere, even outside the package com.enthu.qb.

HTH,
Paul.

Re: About Question enthuware.ocajp.i.v8.2.978 :

Posted: Fri Jul 22, 2016 8:38 am
by christian_burger
Hello Paul,
I see what you mean.
It seemed very misleading to me because we tend to think of the accessibility of the variable itself and forget to put it in that specific context.
Thanks for your answer,
Christian

Re: About Question enthuware.ocajp.i.v8.2.978 :

Posted: Thu Dec 14, 2017 5:36 pm
by Rinkesh
A top level class can only have either public or no access modifier!

can you explain why not private and protected??

Re: About Question enthuware.ocajp.i.v8.2.978 :

Posted: Thu Dec 14, 2017 9:55 pm
by admin
It is a rule of the language and it makes sense too. How would anyone use a top-level class that is private? protected could be argued both ways but I guess the designers of the language felt otherwise.