Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Question about access and visibility

Reply
Thread Tools

Question about access and visibility

 
 
Mark
Guest
Posts: n/a
 
      09-20-2004
OK.

Class Alpha is an abstract base class with package level visibiltiy
and a protected method: protectedMethodAlpha

Class Gamma is a concrete class which inherits from Alpha and
overrides (actually defines) the protected method. It is contained
within the same directory as Alpha

Class Delta is a concrete class which inherits from class Gamma and is
in a different package and has public visibility.

Should class Delta be able to override protectedMethodAlpha?
 
Reply With Quote
 
 
 
 
Michael Borgwardt
Guest
Posts: n/a
 
      09-21-2004
Mark wrote:
> Class Alpha is an abstract base class with package level visibiltiy
> and a protected method: protectedMethodAlpha
>
> Class Gamma is a concrete class which inherits from Alpha and
> overrides (actually defines) the protected method. It is contained
> within the same directory as Alpha
>
> Class Delta is a concrete class which inherits from class Gamma and is
> in a different package and has public visibility.
>
> Should class Delta be able to override protectedMethodAlpha?


Since it's a subclass of Alpha, why not?
 
Reply With Quote
 
 
 
 
Jacob
Guest
Posts: n/a
 
      09-21-2004
Mark wrote:

> Class Alpha is an abstract base class with package level visibiltiy
> and a protected method: protectedMethodAlpha
>
> Class Gamma is a concrete class which inherits from Alpha and
> overrides (actually defines) the protected method. It is contained
> within the same directory as Alpha
>
> Class Delta is a concrete class which inherits from class Gamma and is
> in a different package and has public visibility.
>
> Should class Delta be able to override protectedMethodAlpha?


Yes.

In the discussion, Alpha and Gammas relation to Alpha
is irrelevant. For Delta the interface of Gamma is the
only thing that matters.

Gamma must be public for Delta to extend it from outside
its package. Then Delta can override all of Gammas public
and protected members (including protectedMethodAlpha).


 
Reply With Quote
 
Mark F
Guest
Posts: n/a
 
      09-21-2004
Jacob wrote:
> Mark wrote:
>
>> Class Alpha is an abstract base class with package level visibiltiy
>> and a protected method: protectedMethodAlpha
>>
>> Class Gamma is a concrete class which inherits from Alpha and
>> overrides (actually defines) the protected method. It is contained
>> within the same directory as Alpha
>>
>> Class Delta is a concrete class which inherits from class Gamma and is
>> in a different package and has public visibility.
>>
>> Should class Delta be able to override protectedMethodAlpha?

>
>
> Yes.
>
> In the discussion, Alpha and Gammas relation to Alpha
> is irrelevant. For Delta the interface of Gamma is the
> only thing that matters.
>
> Gamma must be public for Delta to extend it from outside
> its package. Then Delta can override all of Gammas public
> and protected members (including protectedMethodAlpha).
>
>


For some reason when I try to create a project that illustrates this
Class Delta cannot find class Gamma, and I get an error line (red
squiggly line) under "..extends Gamma"

-Mark
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Menu/SiteMap question - visibility Seth Williams ASP .Net 1 05-07-2008 05:29 PM
Nub Question - Details View Visibility randy.buchholz ASP .Net 4 01-08-2008 04:06 PM
Class Visibility Question BG ASP .Net 2 01-30-2005 02:42 PM
[newbie question] Variable visibility Harpo Ruby 2 02-07-2004 06:34 AM
Fundamental question about visibility Casper Bang C++ 51 09-27-2003 09:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57