Puas yog hom kev sib raug zoo hauv Java?
Puas yog hom kev sib raug zoo hauv Java?

Video: Puas yog hom kev sib raug zoo hauv Java?

Video: Puas yog hom kev sib raug zoo hauv Java?
Video: Nrog Vajtswv Sib Raug Zoo (official MUSIC VIDEO) N. Vajxob Xyooj 2024, Kaum ib hlis
Anonim

Hom Kev Sib Raug Zoo . Raws li kev rov siv cov ntaub ntawv cov tswv cuab los ntawm ib chav kawm mus rau lwm chav kawm hauv JAVA peb muaj peb hom kev sib raug zoo . Lawv yog-a kev sib raug zoo , muaj-a kev sib raug zoo thiab siv-a kev sib raug zoo . Siv-a kev sib raug zoo yog ib txoj hauv kev uas ib chav kawm siv ib yam khoom ntawm lwm chav kawm.

Xav txog qhov no, puas muaj kev sib raug zoo java?

Hauv Java , a Has-A kev sib raug zoo tseem hu ua muaj pes tsawg leeg. Hauv Java , a Has-A kev sib raug zoo tsuas yog txhais tau tias ib qho piv txwv ntawm ib chav kawm muaj ib qho kev siv rau ib qho piv txwv ntawm lwm chav kawm lossis lwm qhov piv txwv ntawm tib chav kawm. Piv txwv li, ib lub tsheb muaj ib engine, aub muaj ib tail.

Ib sab saum toj no, puas muaj kev siv kev sib raug zoo? Txhua qhov chaw koj pom cov lus tseem ceeb txuas ntxiv lossis siv lo lus tseem ceeb hauv cov lus tshaj tawm hauv chav kawm, tom qab ntawd chav kawm no tau hais tias muaj IS-A kev sib raug zoo . YOG -A Kev sib raug zoo : Composition( YOG -A) tsuas yog txhais tau tias siv cov piv txwv hloov pauv uas yog siv rau lwm yam khoom. Piv txwv li Maruti muaj Cav, los yog Lub Tsev muaj Chav dej.

Kuj nug, qhov txawv ntawm IS A thiab muaj kev sib raug zoo hauv Java yog dab tsi?

Hauv OOP, IS - A kev sib raug zoo yog qub txeeg qub teg. Qhov no txhais tau tias, cov chav kawm me nyuam yog ib hom niam txiv chav kawm. A HAS-A kev sib raug zoo yog dynamic (khiav lub sij hawm) khi thaum qub txeeg qub teg yog ib qho zoo li qub (sib sau lub sij hawm) khi. Yog tias koj tsuas yog xav rov siv cov cai thiab koj paub tias ob qho tib si tsis zoo siv cov khoom sib xyaw.

ISA kev sib raug zoo yog dab tsi?

ISA kev sib raug zoo . Koj tuaj yeem qhia meej tias ib chav kawm yog subclass ntawm lwm tus los ntawm kev tsim ib qho Isa kev sib raug zoo . Raws li lub neej ntawd, ib Isa node tsuas qhia tau hais tias ib pawg ntawm cov khoom yog subclasses ntawm lwm yam khoom, tab sis tsis muaj dab tsi ntxiv.

Pom zoo: