.
If a class is final, all methods in the class are final.
Expansion and Promotion:
Static,final and abstract are not able to modify the construction method
Class loading
Concept: When the JVM uses a class for the 1th time, it first finds the corresponding. class file from the Classpath, reads all the contents of the file (Properties/Methods/class name/package structure/construction/static ...), and saves the process, called class loadin
implementation of the method is provided by the subclass.Abstract methods cannot be declared as final and abstractAny subclass that inherits an abstract class must implement all the abstract methods of the parent class, unless the subclass is also an abstract classIf a class contains abstract methods, then the class must be an abstract class, but abstract classes do not necessarily contain abstract methods.SynchronizedThe method of synchronized keyword declaration can only be accessed by one th
Compared to C + + in public,proctected, private three access control, Java more than the default access control.Four types of access control permissions in Java are described briefly as four sentences:1) Private only this class is visible (same as C + +)2) default to this package visible/in-package access (C + + not)3) Protected is visible to this package and all subclasses (there is no concept of this pack
Description of the meanings of the access modifiers public, private, protecte, and default in Java:Public (interface access permission): modifier with the widest access restriction in Java, which is generally called "public ". Classes, attributes, and Methods Modified by the package can be accessed not only across classes, but also across packages.Private (you cannot access): the shortest modifier in
Public/protected/private
Public means open, private for privacy, protected for protection, nothing written for default defaults.
Method:
Public protected Default Private
√√√√ in the same class
√√√x in the same package
In the √√xx subclass
√xxx in different packages
Member Variable:
Consider the security and robustness issues, member variables are generally private, and provide some public methods to modify the member variables, in the modified method of input to judge and control.
Pri
Differences between the four access modifiers in java and detailed explanation of the entire process
Client programmers: class consumers who use data types in their applications. Their goal is to collect various classes for fast application development.
Class Creator: A programmer who creates a new data type. The goal is to build a class.
Why access control exists: a. Allow client programmers to not touch w
static properties;Final -The ultimate1, modifier class-The final class, the class cannot be inherited (the purpose is that the class can not be extended, that is, cannot be changed);2, the modification method-the final method, the method can not be overridden by the quilt class;3, modifier attribute-called constant, the name of the constant requires all letters are uppercase, its value cannot be changed, must have initialization;4, modify local variables-final local variables can only be assign
The 1.readonly modifier is used only to decorate a data member of a class. As the name says, once they have been written, directly initialized, or assigned in a constructor, the data member can only read it.The difference between a readonly and a const data member is that const requires you to initialize it directly at the time of declaration.classMyClass {Const intConstint = -;//Proceed directly ReadOnly intMyInt =5;//Proceed directly ReadOnly intMyInt2; PublicMyClass () {MyInt2=8;//the
In Java's interface, the default modifier for member variables is: public static finalSo when we define member variables in the interface, we can1:public static final String name = "Zhang San";2:string name = "Zhang San";Both of the above can be, the old driver is generally the second kind. Since it is a static final variable, it means that you cannot modify the value of this member variable while accessing it outside. Therefore, defining member variables in an interface is generally constant. i
The concept and function of packageConcept:----is physically a folder----Logically a collection of logically related classesRole:----Avoid class names----Controlling access rightsNaming conventions:-----First level refers to the type of the project, such as com,org,gov, etc.------The second level refers to the company name that the project develops or runs, such as: Chinasofti,icss,huawei, etc.-----The third level refers to the name of the project, such as: COREJAVA,BCMS,OA,ERP, etc.-----Fourth
)Package com.zq.demo.test1;/*** In-Class* @author Administrator*/public class Person {Public String uname = "Harry";public void Introducemyself () {System.out.println (uname);}}Package com.zq.demo.test1;Same packagepublic class Student {Person p = new person ();public void Test () {System.out.println (P.uname);}}Package com.zq.demo.test1;Sub-classpublic class Teacher extends person{public int age;Person p = new person ();public void Test1 () {System.out.println (P.uname);}}Package com.zq.demo.te
1, Java has four access modifiers: default/public/private/protected2, they have different access rights, and in different situations and have different access rights, divided into the following several{1, the same kind of{First we write a piece of code to test{
Class Boar
{
void Defmethod ()
{
System.out.println ("default method");
}
protected void Promethod ()
{
System.
The meaning of the access modifier in Java, public, private, PROTECTE, default, is explained:The most restrictive modifier in the Public:java language, commonly referred to as "public". Classes, properties, and methods that are modified by it are notCan be accessed only across classes, and across packages (package).The narrowest modifier for access restrictions in the Private:java language is generally referred to as "private." The classes, attributes
There are four access modifiers in Java: public,protected,default,privateNote: This is about access to the properties and methods in the class, not the access rights of the class1.default: Package access rightsIf nothing is written, default defaults. Of course, you can also explicitly give the default permissionThe properties and methods of the default adornment, all other classes in the package have access
There are four types of access modifiers in Java, private, default, protected, public, and their access rights are raised sequentially, and private can only be called by this class. The default, which defaults to not write, can be called by all classes under the same package, and protected can be called by all classes under the same package, or by subclasses under different packages (that is, there must be
Access modifiersThere are four access rights in Java, and when different access rights are used, the modified content has different access rights, and the following table describes the ability to access different permissions:Public protected Default Private√√√√ in the same classIn the same package (subclass and unrelated classes) √√√Sub-class √√ of different packagesUnrelated classes in different packages Yes summarize: In the daily development proces
Access modifier permissions from high to low are public, protected, default, Private.First, according to "whether is the same package", "whether is sub-category" divided into 4 cases + 5 cases of this type Second, the sub-class in the same package and non-subclasses in the same package are merged into the same package
Access modifiers
This class
Same package
Different packages, sub-categories
Different packages, n
Access modifiers are typically used to modify properties and methods in a class, to constrain access to properties and methods;
Public//This class, the same package, sub-category, others can access;
protected//This class, the same package, the subclass can access, other can not access;
Private//Only this class can be accessed;
Default//Only this class and the same package can be accessed;
java
Four access modifiers in Java:Public (publicly), protected (protected), default, Private (proprietary).They determine the scope of what is immediately followed by what is defined.The smaller the scope Access Rights class Bun class other packagesPublic∨∨∨∨ (available to anyone)Protect∨∨∨x (other classes within the same package and inherited classes can be accessed)DEFAULT∨∨XX (Package access, which can be used by other classes within the same package)P
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.