1.static initialization
The static member variable and the static statement block are executed sequentially when the class byte code corresponding to it is loaded. Such as:
Class.forName ("Test. Statictest ");
At this point, the static member variable in the Statictest class will be initialized and the static statement block will be executed.
2.protected access Rights
Protected corresponding properties and methods can be accessed by classes in the same package, subclasses can access protected properties and methods by reference to subclasses.
In fact, the subclass can inherit the parent class's protected property and method, when the subclass accesses the parent class's protected property and method through its own reference, it actually accesses
The properties and methods that the subclass inherits from itself. Thus, subclasses cannot access the protected property and method through a reference to the parent class. Such as:
Package father;
Public Class father{
protected void Run () {
}
}
Package son;
Public Class Son extends father{
public static void Main (string[] args) {
Father f = new Father ();
F.run ();//Compile error, cannot call parent class's protected method by reference of parent class
Son s = new Son ();
S.run ();//compilation succeeds, the protected method of the parent class can be called through a reference to the child class
}
}
3.finalize Research
When an object cannot be accessed, the system will determine whether the object's Finalize method has been executed, and if it has already been executed, the system will recycle the object;
The object is placed in the F-queue queue waiting for the Finalize method to be executed. When the method is executed, the system will determine whether the object can be accessed, and if so, the object is resurrected, otherwise
will be recycled.
Java Learning Essentials (i)