Page 1 of 1

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

Posted: Mon Oct 24, 2016 7:04 am
by nikitos
Question:

Compared to public, protected and private accessibility, default accessibility is....

I think that: "Less restrictive than protected from within a package, and more restrictive than protected from outside a package." - is right answer.
Is not it?

My meaning:
1 In package we can access to the member of the default access with and without inheritance. If we have protected member - it's not possible to access to the member in same package. So default access is less restrictive than protected from withing a package.

2 If we have two packages a, b and classes a.A, b.B (a,b - package):
If B is-a A (extends A): it's possible to access to the protected member. We will not discuss more details, when it;s not possible access from A reference.
And default access member is not accessible from another package.

Of course, I will choose public>protected>default>private, but if answer will not contain "Less restrictive than protected from within a package, and more restrictive than protected from outside a package."

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

Posted: Mon Oct 24, 2016 7:11 am
by nikitos
My fail is in that:
protected has all that has default (package private) + and more.

Ok. Now it's clear... Think that will helpful for someone.
nikitos wrote:Question:

Compared to public, protected and private accessibility, default accessibility is....

I think that: "Less restrictive than protected from within a package, and more restrictive than protected from outside a package." - is right answer.
Is not it?

My meaning:
1 In package we can access to the member of the default access with and without inheritance. If we have protected member - it's not possible to access to the member in same package. So default access is less restrictive than protected from withing a package.

2 If we have two packages a, b and classes a.A, b.B (a,b - package):
If B is-a A (extends A): it's possible to access to the protected member. We will not discuss more details, when it;s not possible access from A reference.
And default access member is not accessible from another package.

Of course, I will choose public>protected>default>private, but if answer will not contain "Less restrictive than protected from within a package, and more restrictive than protected from outside a package."