JAVA basis overloaded with rewriting his own understanding

Rewrite, also called the cover, it is a subclass reimplement the parent class method.

Overridden in subclasses super method, access to the parent class is not lower than that of the method. Name, returns the result type, to the Senate to be the same with the method of the parent class. Type of exception thrown, not thrown exception types broader than the parent class (subclass exception is not thrown in the parent class).

In a subclass can override the inherited from the parent class method. And, in a final parent class or private modified method can only be called, can not be overridden.

Declared as static type of approach can not be rewritten, but can be re-statement.

When a subclass of a parent class method is overridden the need to call, only the super keyword. Directly call the method, it can only be called to subclass this method. Since this method has subclass, it will not retrieve the parent class.

Parent application variable points subclass instance variable or not call the parent class does not exist.

 Animal b = new Dog();Animal b = new Dog();

Overload means, two methods have the same name in the same class. Because the return type of the method call can not be confirmed, it is necessary to distinguish the parameters passed with the method call, the number of parameters may be different, the order may be different types of parameters. Therefore, the return type, the type of modification, may be the same or different.

Overloading and rewrite the show is too many characteristics of java.

Published 15 original articles · won praise 0 · Views 1069

Guess you like

Origin blog.csdn.net/ma316110/article/details/79447096