Home > Java > Javagetting Started > Are overriding and overloading of methods in Java different manifestations of polymorphism?

Are overriding and overloading of methods in Java different manifestations of polymorphism?

青灯夜游
Release: 2020-10-23 15:59:25
Original
5521 people have browsed it

Yes, rewriting and overloading of methods in Java are different manifestations of polymorphism; overriding is a manifestation of polymorphism between parent classes and subclasses, and overloading (Overloading) is a manifestation of polymorphism in a class.

Are overriding and overloading of methods in Java different manifestations of polymorphism?

(Recommended tutorial: java course)

In Java language, method overriding (Overriding) and Overloading is a different manifestation of polymorphism.

Overriding is a manifestation of polymorphism between parent classes and subclasses, and overloading is a manifestation of polymorphism in a class.

If a method defined in a subclass has the same name and parameters as its parent class, we say that the method is overriding (Overriding). When an object of a subclass uses this method, it will call the definition in the subclass. For it, the definition in the parent class seems to be "shielded".

If multiple methods with the same name are defined in a class, and they have different number of parameters or different parameter types, it is called method overloading.

Overloaded method can change the type of return value.

The above is the detailed content of Are overriding and overloading of methods in Java different manifestations of polymorphism?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template