Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access method

 
Jack Lau
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
My problem is that B has extend A and the doStuff() method in A is protected access, then why B cannot acccess doStuff() ?

Thanks in advance!
Jack
[ June 04, 2003: Message edited by: Jack Lau ]
 
Robbie kyodo
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it seems that there is a mistake
should be
package A;
 
Jack Lau
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I know that why class B cannot access the doStuff() method of class A because protected member can be only seen by subclass through inheritance, but cannot using dot to reference it.
Jack
 
Brian Joseph
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jack,
You're right. But also this question is testing whether you know that protected is very similiar to default (package) access.
If A and B were in the same package, you COULD call A's method like that.
We were just talking about this yesterday and Anupam posted a great link explaining this:
Link To Protected Access Discussion (See Kathy's reply)
[ June 04, 2003: Message edited by: Brian Joseph ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic