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

Moderator: admin

Post Reply
christian_burger
Posts: 4
Joined: Thu Apr 21, 2016 2:46 pm
Contact:

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

Post by christian_burger » Thu Jul 21, 2016 10:45 pm

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

admin
Site Admin
Posts: 8702
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Thu Jul 21, 2016 10:56 pm

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.
If you like our products and services, please help us by posting your review here.

christian_burger
Posts: 4
Joined: Thu Apr 21, 2016 2:46 pm
Contact:

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

Post by christian_burger » Fri Jul 22, 2016 8:38 am

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

Rinkesh
Posts: 35
Joined: Sat Nov 25, 2017 4:13 pm
Contact:

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

Post by Rinkesh » Thu Dec 14, 2017 5:36 pm

A top level class can only have either public or no access modifier!

can you explain why not private and protected??

admin
Site Admin
Posts: 8702
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Thu Dec 14, 2017 9:55 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest