About Question enthuware.ocajp.i.v7.2.1015 :
Moderators: Site Manager, fjwalraven
Re: About Question enthuware.ocajp.i.v7.2.1015 :
Then if it comment line //3, only show 10 and 40. ?
King regards
King regards
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
If you comment only line //3, it will not compile.Enrique wrote:Then if it comment line //3, only show 10 and 40. ?
King regards
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 1
- Joined: Tue Jun 25, 2013 2:52 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
Very good question.
But i believe it's called hiding. I.e. B.i hides A.i. So A.i not inherited by B and therefore not inherited by C.
Best regards
Max
But i believe it's called hiding. I.e. B.i hides A.i. So A.i not inherited by B and therefore not inherited by C.
Best regards
Max
-
- Posts: 25
- Joined: Wed Dec 17, 2014 9:29 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
Hiding or shadowing, both are correct.Loerti wrote: But i believe it's called hiding.
-
- Posts: 16
- Joined: Wed Feb 25, 2015 8:52 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
After reading all of the comments I still don't understand why c can't directly access i in A. If c doesn't inherit i from B because it's private, then why can't c inherit and directly access i in A; i.e., c.i?
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
That is just how the language is designed. You can access A's i but you have to do ( (A)c).i
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
You are right. It is technically "hiding", not shadowing.Loerti wrote:Very good question.
But i believe it's called hiding. I.e. B.i hides A.i. So A.i not inherited by B and therefore not inherited by C.
Best regards
Max
thank you for your feedback!
If you like our products and services, please help us by posting your review here.
-
- Posts: 25
- Joined: Thu Mar 27, 2014 11:35 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
Why will this not compile if //2 is commented out?
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
As the explanation says, "You cannot access c.j because j is private in A."
If you like our products and services, please help us by posting your review here.
-
- Posts: 25
- Joined: Thu Mar 27, 2014 11:35 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
//2 is c.i not c.j. A wrong answer is " It will compile if //2 is commented. " Maybe you mean UNcommented? Pretty sure something is messed up in there. Check it out.admin wrote:As the explanation says, "You cannot access c.j because j is private in A."
-
- Site Admin
- Posts: 10113
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
No, it is correct. If you comment out //2, line marked //3 i.e. c.j will still be there and that won't compile.
If you like our products and services, please help us by posting your review here.
-
- Posts: 25
- Joined: Thu Mar 27, 2014 11:35 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1015 :
Ok, I get it. It will compile if //2 is commented out, yet that won't fix the problem that keeps it from compiling...
If you wanted to be clearer you could change that answer to read "commenting //2 will allow it to compile."
If you wanted to be clearer you could change that answer to read "commenting //2 will allow it to compile."
Who is online
Users browsing this forum: No registered users and 4 guests