1. Initialization of the object (1) Initialization of non-static objects When the object is created, all data members of the object are initialized first. Basic Type: INT type, initialization is 0. If objects: These objects are initialized in order. ※ The construction method of this class is invoked after all class members initialize the completion. The role of the constructor is to initialize. (2) The static variable of the primary class in the initialization program of the static object will initialize before the MAIN method. Not only when the object is created, all static variables in the class are initialized, and all static variables are also in the class when accessing a static object of a class (note that this type of object) is accessed. The order initialization. 2. When inheriting, the initialization process of the object (1) The superclass of the primary class is initially initialized by high to low, regardless of whether static members are private. (2) Initialization of the static member of the primary class. (3) The superclass of the primary class is called by the default constructor by high to low. Note that before the default constructor of each superclass is called, the initialization of this superclass is performed in advance. (4) Initialization of the main class of non-static members. (5) Call the constructor of the primary class. 3. About the constructor (1) category may have no construction method, but if there is a number of constructors, there should be a default constructor, otherwise, when inheriting this class, you need to call the parent class in the subclass. A non-default constructor. (2) In a construction method, only other configuration methods can only be called, and the statement that calls the constructor must be the first statement. 4. Categories where public, private, and protected (1) without public modification, can be accessed by other classes: A. Two classes are in the same file, b. Two classes are in the same folder, c. Two A class is in the same package. (2) Protected: Inherited class and the same package can be accessed. (3) If the constructor is private, the object cannot be created in other classes. 5, abstract class (1) abstract class cannot create objects. (2) If a method in a class is an abstract method, this class must be an Abstract abstraction class. (3) Inheriting the abstract class class must implement an abstract method in an abstract class in the class. (4) There is an abstract method in the abstract class, or there may be a non-abstract method. Abstract methods cannot be private. (5) The class of indirect inheritance abstraction may not give the definition of abstract methods. 6. Final Keywords (1) An object is constant, does not mean members who cannot transform the object, can still operate their members. (2) The constant must be assigned before use, but in addition to initialization while the declaration, it can only be initialized in the construction method. (3) Final modified method cannot be reset (the same name method can not appear in the subclass). (4) If a class is final, all methods are final, regardless of whether it is finaled, but the data member can be Final is not. 7. Interface Interface (Implement) (1) All data in the interface is static and final, ie static constants. Although it is necessary to modify these two keywords, it must be assigned to constant quantities. (2) The method in the interface is public, in the interface class, the implementation method must be a PUBLIC keyword. (3) If you use public to modify the interface, the interface must be the same as the file name. 8, multiple inheritance (1) A class inherits a class and interface, then the class must be written in front, the interface is written behind, and the interface is separated by a comma. (2) Multiple inheritance between the interfaces, pay attention to use keyword extends. (3) Although a class only implements an interface, but not only to implement all the methods of this interface, but also the method of the interface inherited by this interface, all the methods in the interface must be implemented in the class.
9, the embedding (1) interface of the interface is embedded in the class, you can use private modification. At this point, the interface can only be implemented in the class, and other classes cannot be accessed. (2) The interface in the embedded interface must be public. 10. Embed (1) classes of the class can be embedded in another class but cannot be embedded in the interface. (2) In a static method or other method, an internal class object cannot be created directly, and it is necessary to obtain by means. There are two means: Class a {class b {} b getb () {b b = new b (); return b;}} static void m () {a a = new a (); ab ab = a.Getb (); // or ab ab = a.new b ();} (3) A class inherits the internal class of another class, because the superclass is the internal class, and the internal class constructor cannot be called automatically. This needs to be clearly invoked in the structure method of the subclass. Conclusion: Class C Extends A.B {c () {new a (). Super (); // This sentence implements calls to the internal structure method. }} The structure method can also be written: c (a a) {a.super ();} // use this constructor to create an object, to write into c c = new c (a); A is an object of A. 11. Except for the RuntimeException class in an exception class, other exceptions must be captured or thrown.