Koj sau ib txoj kev paub daws teeb meem li cas?
Koj sau ib txoj kev paub daws teeb meem li cas?

Video: Koj sau ib txoj kev paub daws teeb meem li cas?

Video: Koj sau ib txoj kev paub daws teeb meem li cas?
Video: Yuav tawm ntawm txoj kev txom nyem tau li cas? 2024, Kaum ib hlis
Anonim

Tshaj tawm ib abstract method , siv daim ntawv no: abstract hom txoj kev - lub npe (parameter-list); Raws li koj tau pom, tsis muaj txoj kev lub cev tam sim no. Txhua yam pob zeb chav kawm (i.e. chav kawm tsis muaj abstract keyword) uas extends ib chav kawm abstract yuav tsum override tag nrho cov abstract txoj kev ntawm chav kawm.

Ib yam li ntawd, txoj kev paub daws teeb meem yog dab tsi?

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.

Tsis tas li ntawd, dab tsi yog qhov xav tau rau cov chav kawm paub daws teeb meem thiab kev paub daws teeb meem? abstract lo lus tseem ceeb yog siv los tsim ib qho chav kawm abstract thiab txoj kev . Abstract chav kawm hauv java yuav tsis tau instantiated. Ib chav kawm abstract feem ntau yog siv los muab lub hauv paus rau subclasses kom txuas ntxiv thiab siv tau abstract txoj kev thiab override los yog siv cov kev siv txoj kev hauv chav kawm abstract.

Hais txog qhov no, thaum siv cov kev paub daws teeb meem?

Abstract Cov chav kawm yog qhov haum zoo yog tias koj xav muab cov ntsiab lus siv rau koj cov menyuam tab sis tsis xav tso cai rau ib qho piv txwv ntawm koj chav kawm kom ncaj qha ncaj qha (uas tso cai rau koj los txhais cov chav kawm ib nrab). Yog tias koj xav kom yooj yim txhais daim ntawv cog lus rau Cov Khoom Ua raws li, ces siv qhov Interface.

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

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.

Pom zoo: