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."
About Question enthuware.ocajp.i.v8.2.1053 :
Moderator: admin
-
- Posts: 21
- Joined: Mon Oct 24, 2016 6:55 am
- Contact:
-
- Posts: 21
- Joined: Mon Oct 24, 2016 6:55 am
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1053 :
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.
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."
Who is online
Users browsing this forum: Bing [Bot] and 150 guests