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
About Question enthuware.ocajp.i.v8.2.978 :
Moderator: admin
-
- Posts: 4
- Joined: Thu Apr 21, 2016 2:46 pm
- Contact:
-
- Site Admin
- Posts: 10043
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.978 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Thu Apr 21, 2016 2:46 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.978 :
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
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
-
- Posts: 35
- Joined: Sat Nov 25, 2017 4:13 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.978 :
A top level class can only have either public or no access modifier!
can you explain why not private and protected??
can you explain why not private and protected??
-
- Site Admin
- Posts: 10043
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.978 :
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.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Google [Bot] and 39 guests