Home > Back-end >  Java polymorphic forms
Java polymorphic forms

Time:09-17

What Java polymorphism, form, method of overloading count

CodePudding user response:

1, 2 method overloading, rewriting the 3, abstract class 4, interface

CodePudding user response:

Polymorphism is the parent class reference is to subclass object?

CodePudding user response:

Implementing an interface, or, inherit the superclass, and then, when using, an interface or super class programming,

CodePudding user response:

Polymorphism: 1, the upward transition: the parent class reference is to subclass object
2, strong downward transition: the superclass object into a subclass object (consistency)

Polymorphism of the role is to improve the flexibility of the code, often in the reference and use,

Realize there are three necessary conditions: polymorphic inheritance, rewrite (static polymorphism), upcasting,

Method overloading (dynamic polymorphism) requirement is: the same method name and argument list different (different parameter types or parameters order or number), as for the rest of the way, such as the method return value types and modifiers, and the method overloading has nothing to do, plus the best @ Overload annotations,

So, from a certain perspective, overloading is overloaded polymorphism is polymorphism, method overloading is not polymorphic forms of

CodePudding user response:

Polymorphism of typical -- generics

CodePudding user response:

Polymorphism is simply the same name have different implementations, method overloading and rewritten, interface and so on all are polymorphic,
  • Related