• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Protected class

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there such thing as a class with the protected access modifier? I mean, can a class be defined visible only to its peers in the same package and subclasses of the outer-package-world? What are the modifiers that ca be applied to classes?

Any considerations are much welcome.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>Is there such thing as a class with the protected access modifier?
Well yes, inner classes can be protected. They could be private and static too (all these modifiers cannot be applied to Outer level classes)

>I mean, can a class be defined visible only to its peers in the same package and subclasses of the outer-package-world? What are the modifiers that ca be applied to classes?
High level classes/Outer classes/ie non-inner classes have only 2 modifiers - public or no modifier (public class X or class X). public classes are visible everywhere and the no-modifier one is visible only inside the pkg (to all sub-classes and non-sub-classes in the pkg).

Tx,
ram.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Top level classes can only be public and friendly, but there can be only one public class per one source file.these are the access modifiers that can be applied to a classes(Top level).

Yasith Vidanaarachchi
---------------------
SCJP 1.4
[ January 28, 2005: Message edited by: Yasith Vidanaarachchi ]
 
Philip Pomario
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, guys!
 
Philip Pomario
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just passed the SCJP1.4 exam and wanted to post this appreciation note to thank everyone who helped me understand Java a little better. Without your help this personal achievement wouldn't be possible.
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic