C#
The below table is taken from the book C# Language Specs:In same namespace, the default for non-nested class must be internal or public.
Accessibility
|
Meaning
|
public
|
Access not limited
|
protected
|
Access limited to this class or classes derived from this
class
|
internal
|
Access limited to this program
|
protected
internal
|
Access limited to this program or classes derived from this
class
|
private
|
Access limited to this class
|
Defaults:
The default for non-nested types is internal. The default for nested types is private. In both cases the default (for classes) is unsealed. The general rule for all members is that if you don't specify an access modifier, it's as private as it can be. The single exception for this is properties which can make one part (i.e. the getter or the setter) more private than the overall property by specifying an access modifier, e.g. (Jon Skeet)
Java
The below table belongs to Oracle, http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.htmlModifier | Class | Package | Subclass | World |
---|---|---|---|---|
public |
Y | Y | Y | Y |
protected |
Y | Y | Y | N |
no modifier | Y | Y | N | N |
private |
Y | N | N | N |
0 comments:
Post a Comment