The key points of knowledge are summarized as follows:
1, abstraction, encapsulation, inheritance, polymorphism are the four characteristics of object-oriented programming.
2, object-oriented software development is generally divided into: object-oriented analysis, object-oriented design, object-oriented implementation.
This can be summarized as follows: Analyzing user requirements, extracting object models from problems, refining models, designing classes, including properties of classes and classes
, and observe whether there are existing classes or parts that can be directly referenced; Select an object-oriented programming language, the specific coding implementation
The design of the previous stage class, and the introduction of testing in the development process, to improve the whole solution.
3, the advantages of object-oriented programming methods are: reusability, scalability, manageability.
4, class definition: The modifier before class is divided into the access control character and the non access control character. Access control characters include public and private.
Non-access control characters include abstract (abstract), final (end).
The 5,final class is the final class and is a class that cannot have subclasses. Abstract and final cannot modify a class at the same time because the abstract class itself has no concrete objects,
The object to create the subclass after the subclass is derived. And the final class cannot have subclasses.
6, the object is created in the form of a class name object name =new constructor method (parameter); Note that the preceding class name is the constructor method.
Note that the constructor method has no return type and cannot write void, it is mainly used to complete initialization of class objects, and can not be directly programmed by
Called directly, but is invoked with the new operator.
7, if class is preceded by a public modifier, the default constructor should also have a public modifier before it.
8, the class has a static decorated domain or method, can be accessed by the class name or object name, otherwise it can only be accessed with the object name.
9, the access control character for the decorated field can be: public,private,protected,private protected. The non-access control character can be:
Static,final,volatile (volatile domain)
10, the most essential feature of class variables is that they are the domain of a class and do not belong to a specific object instance of any class. Instead of being saved in the memory space of an object instance, it is stored in a common storage cell in the memory area of the class.
11, local variables are declared in the method body and they exist only if the method is invoked, so they can only be used within this method, there is no access control character, and cannot be declared as static (static), but can be declared as final. Local variables must be initialized.
12, the access control character of the cosmetic method can be: Public,private,protected,private protected, the non-access control character of the adornment method can be: static,final,abstract,native (local method), Synchronized (synchronous method).
13, variables or methods decorated with static are class members, class members can be accessed with class names or instance names, and instance members can only be accessed with instance names.
14, if a class contains abstract methods, this class must be an abstract class, and if the subclass of the abstract class is not an abstract class, then the subclass must implement all the abstract methods of the parent class. Abstract methods cannot use static methods and final methods. The method of pumping is only the declaration of the function header, and the semicolon is substituted for the method body, without the curly braces. such as abstract void Abstractmethod ();
15,this variables are used inside a method, pointing to the current object, which refers to the object that invokes the currently executing method. A super variable is a construction method that directly points to the parent class, and is used to refer to the variables and methods of the parent species. (because they refer to objects, they cannot refer to class variables and class methods)
16, if you want to refer to multiple classes in a package, you can use an asterisk instead. Using asterisks only represents all classes in this hierarchy, not the classes under the child hierarchy. So often need to use two statements to introduce two levels of class: Import Java.awt.*;import java.awt.event.*;
17, Access modifier:
-A member of a class that is restricted to public can be accessed by all classes.
--The members of a class that first locate private can only be accessed by the class itself. Different objects of the same class can access each other's private domain variable or call the other's domain method because Access protection is controlled at the class level, not at the level of the object.
-A member of a class that is limited to protected can be accessed by the class itself, its subclasses (including subclasses in the same package and different packages), and other classes in the same package.
A member decorated with private protected can be accessed by the class itself or by all subclasses of the class.
--The default access control character can be accessed and referenced only by classes in the same package, not by classes in other packages. That is, his access rights are friendly.
18, note:
----abstract and private,static,final,native cannot modify the same method in parallel.
----fields and methods in an abstract class that cannot be decorated with private
----static method cannot handle fields that are not static.
19, the parameters of the overloaded method must be different, or the number of arguments is different, or the parameter type is different. Multiple methods that are overloaded must return the same data type.
20, in Java, a class that gets the functionality defined by an interface is not implemented directly by inheriting the properties and methods of the interface. Because the properties in the interface are constants, the interface method is an abstract method without a method body, and there is no specific definition of the operation.