1: Dynamic binding and static binding
Use static bindings with variables or methods that are private or static or final decorated. The virtual method (which can be overridden by the quilt Class) is dynamically bound according to the object at run time;
Static bindings are done using class information, while dynamic binding requires the use of object information to complete
The overloaded (overload) method uses a static binding to complete, while the overridden method uses dynamic binding to complete;
2: Access modifier public,private,protected, default
Defaults to default when members of a class do not write access adornments. The default is equivalent to exposing (public) to other classes in the same package, and for other classes that are not in the same package are equivalent to private (private). A protected (protected) subclass is equivalent to exposing a class that is not a parent-child relationship in the same package as private. Summarize the following table:
The meaning of 3:final:
Final can be decorated with classes, methods, variables:
The final modified class cannot be inherited;
The final modified method cannot be overridden; (Note: If the parent class is private final, the subclass can define a function with the same name, which is equivalent to defining a new method, not a rewrite; otherwise there is a compilation error)
The final modified variable is not changed (note: The base type value cannot change if it is a primitive type; If you point to an object, the contents of the object can be changed)
4:abstract Class (abstract Class) VS interface (interface)
Abstract class: Cannot create an object (JVM can?) But you can create references;
Abstract methods (the name of an abstract modifier): There is a definition of method name, no implementation;
Classes that contain abstract methods are abstract classes, but abstract classes do not necessarily contain abstract methods.
A class inherits an abstract class, and it must implement an abstract method of the abstract class, otherwise this class is also an abstract class.
Abstract cannot be in conjunction with final,private,static;
The interface is a special abstract class in which the constants are public,static,final, and the methods are all public abstract. Since this is the case, these modifiers can be omitted directly when defining the interface. (No wonder the interface generally does not define attributes);
The methods of interface are abstract methods;
An interface cannot create an object, but can declare a reference to an interface type;
Implements (VS extends
If you don't want the subclass to be abstract, implement all the abstract methods inside the interface. The public cannot be less when implementing the method
Interfaces support multiple inheritance, but abstract classes do not;
Abstract class VS interface;
A class can inherit a parent class at the same time, implementing multiple interfaces;
The advantages of both: interfaces can be multiple inheritance, abstract classes can have a default implementation method, interface cannot.
5:instanceof: Judging Whether it is an instance of a type; It is important to use this in the downward transition.
When will the 6:tostring () automatically be called?
"Object + string" will automatically call the object's ToString () function;
7: How does the constructor call?
The code we write can only call the constructor at the top of the constructor.
8: Can I use the return value to differentiate whether it is overloaded? No
9: Default constructor: If the constructor is not written, a default constructor is created, and if it is written, there is no default constructor.
10:java Why not sizeof? Because there is no need, there is no cross-platform problem, the size of the various types is fixed;
One: = = = VS equals: = =: Compare whether the reference is a; equals: compare content
12: Default value for Basic member: Boolean false; char null; byte:0; int 0; Long 0L; float 0.0f; Double 0.0d
JAVA Programming Idea One