About Question enthuware.ocajp.i.v7.2.1015 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Enrique

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by Enrique »

Then if it comment line //3, only show 10 and 40. ?

King regards

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

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by admin »

Enrique wrote:Then if it comment line //3, only show 10 and 40. ?

King regards
If you comment only line //3, it will not compile.
HTH,
Paul.

Loerti
Posts: 1
Joined: Tue Jun 25, 2013 2:52 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by Loerti »

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

coder007
Posts: 25
Joined: Wed Dec 17, 2014 9:29 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by coder007 »

Loerti wrote: But i believe it's called hiding.
Hiding or shadowing, both are correct.

dmcinnis1
Posts: 16
Joined: Wed Feb 25, 2015 8:52 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by dmcinnis1 »

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?

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

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by admin »

That is just how the language is designed. You can access A's i but you have to do ( (A)c).i

HTH,
Paul.

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

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by admin »

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
You are right. It is technically "hiding", not shadowing.
thank you for your feedback!

__Bill
Posts: 25
Joined: Thu Mar 27, 2014 11:35 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by __Bill »

Why will this not compile if //2 is commented out?

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

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by admin »

As the explanation says, "You cannot access c.j because j is private in A."

__Bill
Posts: 25
Joined: Thu Mar 27, 2014 11:35 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by __Bill »

admin wrote:As the explanation says, "You cannot access c.j because j is private in A."
//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
Site Admin
Posts: 10385
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by admin »

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.

__Bill
Posts: 25
Joined: Thu Mar 27, 2014 11:35 am
Contact:

Re: About Question enthuware.ocajp.i.v7.2.1015 :

Post by __Bill »

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."

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests