Overloading and Overwrite:
1. Overloading (overloading):
Java's method overloading, is that you can create multiple methods in a class, they have the same name, but with different parameters and different definitions, call the method by passing to them the number of different parameters and parameter types to determine which method to use, which is polymorphism;
When overloaded, the method name is the same, but the parameter type and number are different, and the return value type can be the same or different.
2. Overwrite (overriding):
The polymorphism between the parent and child classes, redefining the functions of the parent class. If you define a method in a subclass that has the same name and parameters as its parent class, we say that the method is overridden. In Java, subclasses can inherit methods from the parent class without having to rewrite the same method. But sometimes subclasses do not want to inherit the parent class's methods, but want to make some changes, which requires a method of rewriting. Method overrides are also called method overrides;
If a method in a subclass has the same method name, return type, and parameter table as a method in the parent class, the new method overwrites the original method.
Scope of the class
public>protected>friendly>protected
Class inside this Bun class outer package
Public√√√√
Protected√√√x
Default√√xx
Private√xxx
Inheritance and Interfaces
1. Inheritance: Single inheritance, we say that the inheritance of the class is generally inherited from the attribute is-a relationship of things, inheritance is to reduce the redundancy of the Code;
2. Interface: Multi-implementation, is generally the implementation of the behavior of things, interface is the template to achieve the corresponding method;
Java Object-oriented features
1. Encapsulation
Encapsulation is one of the object-oriented features and is the main feature of object and class concepts. Encapsulation is the process and data is surrounded, access to data only through the defined interface
2. Abstraction
Abstraction is about ignoring aspects of a topic that are not relevant to the current goal in order to pay more attention to the aspects related to the current goal
3. polymorphic
Polymorphism refers to allowing objects of different classes to respond to the same message
4. Inheritance
Inheritance is a hierarchical model of a junction class and allows and encourages the reuse of classes, which provides a way to articulate commonalities.
Java's significant change to C + + is the garbage collection mechanism;
Java Programming Ideas (20170816)