Outline:
The OOP method provides a means to restructure data and methods. Three basic features: encapsulation, inheritance, and Polymorphism
1) classes, fields, and methods
Class Definition: [class modifier] class name [extends parent class name] [implements Interface Name List] {class body}
Method definition: each method must belong to a class. [method modifier] return type method name (method parameter list) {method body}
The constructor is automatically called when a new object is created. It is generally used to initialize fields. The default constructor first calls the default constructor of the parent class. The Destructor is automatically processed by the Java Virtual Machine spam processor. Finalize () is called by Java before the object is to be recycled, and no value (void) is returned without parameters ). Parameters are passed in the method.
Field definition.
2) Encapsulation of Class Members
Access Control for members:
Public Members can access similar members, same-package members, and subclasses.
Members with protected can access similar members, same-package members, and subclasses.
Members with the default value can access similar members and members in the same package.
Private Members can access similar members.
Class Access Control: public and default (class with the same package can be accessed)
3) Some keywords:
This and abstract (abstract methods can only be methods in abstract classes. They only provide method headers. abstract classes must be explicitly specified and cannot be instantiated) the final field defines the constant private final int INCRA = 0. The final method cannot be overwritten by the quilt class, and the final class cannot be inherited. Static.
Abstract methods are abstract methods and only function headers are provided. abstract classes are abstract classes. The relationships between them are: the classes that define abstract methods must be abstract classes, and abstract classes do not necessarily define abstract methods.
4) Inheritance
Extends. The subclass adds new fields and methods to adopt the old fields and methods. Whether the instanceof test object is a certain type of instance.
5) polymorphism
Static overload and dynamic coverage. The super keyword calls a member of the parent class. Use the parent class reference to point to the subclass object to call the subclass method with the same name.
6) Interface
Interface. The method is abstract, and the field is final or static. It must be public.
7) package
Create package: Package com. Google. Soap. search;
AddProgramMedium
8) internal class
Similar to the member method. Instantiate an internal class in a similar method and assign a value to the identifier.
Anonymous internal class: (New construtfunc () {funcdef })