Dab tsi yog qhov xav tau rau cov chav kawm paub daws teeb meem thiab kev paub daws teeb meem?
Dab tsi yog qhov xav tau rau cov chav kawm paub daws teeb meem thiab kev paub daws teeb meem?

Video: Dab tsi yog qhov xav tau rau cov chav kawm paub daws teeb meem thiab kev paub daws teeb meem?

Video: Dab tsi yog qhov xav tau rau cov chav kawm paub daws teeb meem thiab kev paub daws teeb meem?
Video: Yuav tawm ntawm txoj kev txom nyem tau li cas? 2024, Kaum ib hlis
Anonim

Cov chav kawm Abstract . Abstract (uas Java txhawb nrog abstract keyword) txhais tau hais tias tus chav kawm los yog txoj kev los yog teb los yog dab tsi tsis tuaj yeem instantiated (uas yog, tsim) qhov twg nws tau txhais. Lwm yam khoom yuav tsum instantiate cov khoom nyob rau hauv nqe lus nug. Yog koj ua ib chav kawm abstract , koj tsis tuaj yeem instantiate ib yam khoom los ntawm nws.

Nyob rau hauv no hais txog, dab tsi yog lub ntsiab lus ntawm cov chav kawm abstract?

Lub hom phiaj ntawm ib chav kawm abstract yog los txhais qee tus cwj pwm uas tuaj yeem tau txais los ntawm ntau lub subclasses, tsis tas siv tag nrho chav kawm . Hauv C#, lub abstract lo lus tseem ceeb xaiv ob qho tib si chav kawm abstract thiab ib txoj kev ntshiab virtual.

Ib sab saum toj no, qhov txawv ntawm chav kawm abstract thiab abstract method yog dab tsi? A txoj kev uas tau tshaj tawm siv lo lus tseem ceeb abstract npe a abstract method . Cov kev paub daws teeb meem yog tshaj tawm xwb thiab nws yuav tsis muaj kev siv. Ib Java chav kawm muaj ib chav kawm abstract yuav tsum tau tshaj tawm tias chav kawm abstract . Ib abstract method tuaj yeem teeb tsa lub visibility modifier, ib qho ntawm pej xeem lossis tiv thaiv.

Tsuas yog li ntawd, nws puas yuav tsum muaj txoj kev paub daws teeb meem hauv chav kawm paub daws teeb meem?

Tsis yog tsim nyog rau ib chav kawm abstract rau muaj abstract method . Java Abstract chav kawm tuaj yeem siv interfaces yam tsis tau muab kev siv interface txoj kev . Java Abstract chav kawm yog siv los muab ntau txoj kev kev siv rau tag nrho cov subclasses los yog muab defaulting.

Dab tsi yog txoj kev paub daws teeb meem?

Ib abstract method yog a txoj kev uas tau tshaj tawm, tab sis tsis muaj kev siv. Abstract cov chav kawm yuav tsis tau instantiated, thiab yuav tsum tau subclasses los muab kev siv rau cov abstract txoj kev . Cia peb saib ib qho piv txwv abstract class, ib abstract method.

Pom zoo: