This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

private protected??  RSS feed

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is this private protected modifier?is it same as default modifier?
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Sandya Bhaskara:
what is this private protected modifier?is it same as default modifier?



private and protected are two different accessibility modifiers. private and protected are similar in that they apply only to members. private means that the member is not accessible from any other class -- even subclasses (nested classes can access private members in their top-level class). it is usually applied to fields and helper methods for classes. protected is not as restrictive, as it allows for access by classes that are either in the same package, or subclasses of that class.

c
[ August 23, 2004: Message edited by: Chris Wash ]
 
Sandya Bhaskara
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops.... i was sure that there was no "private protected" modifier... actually this was the question asked in a mock test..what is private protected modifier?..and some options were given ..i got doubt if there was a "private protected" modifier which i didn't know of...anyway the answer was none of the above...
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
there is a "private protected" modifier but it is not supported in the current java version. 1.2

it allows access only to the subclasses in the same package.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!