Dab tsi yog universal polymorphism?
Dab tsi yog universal polymorphism?

Video: Dab tsi yog universal polymorphism?

Video: Dab tsi yog universal polymorphism?
Video: FOOM XAIS YOB II HMONG DUBBED JET LI MOVIE 2024, Kaum ib hlis
Anonim

Universal Polymorphism . Cov cim uas yog universally polymorphic tuaj yeem xav tias muaj pes tsawg tus ntawm ntau hom sib txawv. Muaj ob hom universal polymorphism : parametric thiab subtyping.

Ntxiv rau qhov no, polymorphism thiab piv txwv yog dab tsi?

Lo lus polymorphism txhais tau tias muaj ntau hom. Hauv cov lus yooj yim, peb tuaj yeem txhais tau polymorphism raws li lub peev xwm ntawm cov lus yuav tsum tau tso tawm nyob rau hauv ntau tshaj ib daim ntawv. Lub neej tiag tiag piv txwv ntawm polymorphism , ib tug neeg nyob rau tib lub sij hawm tuaj yeem muaj cov yam ntxwv sib txawv. Zoo li ib tug txiv neej tib lub sijhawm yog leej txiv, tus txiv, ua haujlwm.

Kuj Paub, txhais li cas los ntawm parametric polymorphism? Parametric Polymorphism yog ib txoj kev mus txhais hom lossis cov haujlwm uas muaj ntau dua lwm hom. Lub genericity yuav qhia tau los ntawm kev siv hom variables rau cov parameter hom, thiab los ntawm ib tug mechanism kom meej meej los yog implicitly hloov hom variables nrog pob zeb hom thaum tsim nyog.

Ib yam li ntawd, koj tuaj yeem nug, koj txhais li cas los ntawm polymorphism?

Polymorphism yog ib lub tswvyim hais txog kev ua haujlwm uas hais txog lub peev xwm ntawm qhov sib txawv, muaj nuj nqi lossis khoom siv los ua ntau hom ntawv. Ib hom lus uas nta polymorphism tso cai rau cov neeg tsim khoom los ua qhov program hauv qhov dav dav es tsis yog qhov program hauv qhov tshwj xeeb.

Qhov txawv ntawm polymorphism yog dab tsi?

Polymorphism hauv Java muaj ob hom : Sau lub sijhawm polymorphism (static binding) thiab Runtime polymorphism (dynamic binding). Txoj kev overloading yog ib qho piv txwv ntawm static polymorphism , thaum txoj kev overriding yog ib qho piv txwv ntawm dynamic polymorphism.

Pom zoo: