Dab tsi yog qhov txawv ntawm chav kawm abstract thiab abstract method?
Dab tsi yog qhov txawv ntawm chav kawm abstract thiab abstract method?

Video: Dab tsi yog qhov txawv ntawm chav kawm abstract thiab abstract method?

Video: Dab tsi yog qhov txawv ntawm chav kawm abstract thiab abstract method?
Video: TUDev's Tech Talk with Professor Bora Ozkan - Fintech and the Future of Finance 2024, Hlis ntuj nqeg
Anonim

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. Ntawd yog, ib abstract method tsis tuaj yeem ntxiv qhov zoo li qub lossis qhov kawg hloov kho rau cov lus tshaj tawm.

Ib yam li ntawd, dab tsi yog chav kawm abstract thiab abstract method?

Cov chav kawm Abstract tsis tuaj yeem ua instantiated, tab sis lawv tuaj yeem raug subclassed. Ib abstract method yog a txoj kev uas tau tshaj tawm yam tsis muaj kev siv (tsis muaj braces, thiab ua raws li lub semicolon), zoo li no: abstract void moveTo(double deltaX, double deltaY);

Tsis tas li ntawd, lub ntsiab lus ntawm cov chav kawm abstract yog dab tsi? 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.

Ntawm no, dab tsi yog chav kawm abstract thiab txoj kev?

A chav kawm uas tau tshaj tawm tias siv abstract ” lo lus tseem ceeb yog hu ua chav kawm abstract . Nws tuaj yeem muaj abstract txoj kev ( txoj kev tsis muaj lub cev) nrog rau pob zeb txoj kev (ib txwm txoj kev nrog lub cev). Ib chav kawm abstract tsis tuaj yeem instantiated, uas txhais tau hais tias koj tsis raug tso cai los tsim ib yam khoom ntawm nws.

Koj sau cov chav kawm abstract li cas?

Tsim ib qho chav kawm abstract , tsuas yog siv cov abstract lo lus tseem ceeb ua ntej chav kawm keyword, hauv chav kawm tshaj tawm. Koj tuaj yeem saib qhov ntawd tsuas yog abstract cov txheej txheem cov neeg ua haujlwm chav kawm zoo ib yam li qub chav kawm hauv Java. Cov chav kawm yog tam sim no abstract , tab sis nws tseem muaj peb lub teb, xya txoj kev, thiab ib tus tsim.

Pom zoo: