 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
polilop Guest
|
Posted: Thu Jun 16, 2005 10:56 pm Post subject: newbe Q |
|
|
i have an abstract class (person) with abstract methods
allso i have in that abstract class variables (name, surename, age), it is
inhereted by classes like
proffesor, student...
what access modifier should i put?
I can not put private only public and protected?
what is the difference between public and protected?
The problem is that whichever i put i can allways get to the variables in
the superclass becouse i can not put private access modifier.
|
|
| Back to top |
|
 |
Remi Arntzen Guest
|
Posted: Fri Jun 17, 2005 6:52 am Post subject: Re: newbe Q |
|
|
Public member fields are just that "public" any class that has access
to the Declaring class "person" has access to the fields "name,
surname, age".
Protected member fields are "protected" from other classes, in that any
other class that does not extend class "person" can not access the
fields "name, surname, age", however the classes "professor,
student..." can access the fields, because they extend (are subclasses
of) "person".
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|