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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

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 »

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: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
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 »

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 »

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: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.
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 43 guests