In Java:
The access permissions in Java include public, private, protected, and default package access permissions. If the attribute methods in the class do not show the specified access permission, the package access permission is granted, I like
Summary:Within a class, its members (including member variables and member methods) can be interviewed by other classes, depending on the modifier of that member, and whether a class can be visited by other classes depends on the class's modifiers.
1. Protected access control characters can be used for methods and member variables.
2. Methods and member variables declared as protected can be accessed by all classes in the same package, just like the default modifier package.
3. Can be accessed
For Java programmers, Java access rights modifiers public, protected, default, private and the difference between the use is certainly not a problem, here is no longer verbose, anyway, niang a search on a lot of. Recently, when finishing the
In Java, the three reserved words are used to modify the data members and member functions of the class, and the class itself. In C ++, the data members and member functions of the modifier class, and the inheritance of the class, but you don't need
Protectedto talk about the protected access rights issue. Look at example 1 below:Test.java
Class MyObject {} public
class Test {public
static void Main (string[] args) {
MyObject obj = new MyObject (); C5/>obj.clone (); Compile
In fact, this is simply a saying: "A subclass that is not in the same package as the base class can only access protected members inherited from the base class, you cannot access the protected members of the base-class instance ".
Original works
1. What is a Java Virtual Machine?A Java virtual machine is an imaginary machine that is simulated by software on an actual computer. The Java Virtual Machine has its own hardware, such as the processor, stack, and register. It also has the
Why cannot private and protected be used for classes and interfaces? Private, protected, default, and privateprotected cannot be used for interface methods.
For java programmers, the differences and usage of the access permission modifiers public,
Analysis of Java decoration appended public default protected private static final abstractthe function of a modifier: used to define a class, method, or variable, usually at the front end of a statementTwo classification (broadly divided into two
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.