Dab tsi yog kev siv super lo lus tseem ceeb?
Dab tsi yog kev siv super lo lus tseem ceeb?

Video: Dab tsi yog kev siv super lo lus tseem ceeb?

Video: Dab tsi yog kev siv super lo lus tseem ceeb?
Video: Siv Yis Neeb Leej Cawm Seej Music Video Short 2024, Tej zaum
Anonim

Kev siv ntawm Java super Keyword

super tuaj yeem siv los xa cov niam txiv tam sim hauv chav kawm piv txwv hloov pauv. super tuaj yeem siv los hu rau niam txiv tam sim hauv chav kawm. super() tuaj yeem siv los hu tam sim niam txiv chav tsim tsim.

Nyob rau hauv txoj kev no, dab tsi yog qhov kev siv tseem ceeb ntawm Super lo lus tseem ceeb?

Cov super lo lus tseem ceeb hais txog superclass (niam txiv) khoom. Nws yog siv hu rau superclass txoj kev, thiab nkag mus rau superclass constructor. Feem ntau feem ntau siv lo lus super yog kom tshem tawm qhov tsis meej pem ntawm superclasses thiab subclasses uas muaj cov txheej txheem nrog tib lub npe.

Qhov thib ob, dab tsi yog qhov kawg thiab super lo lus sib txawv ntawm lawv? Qhov txawv ntawm super thiab kawg Java super vs kawg Java yog lo lus tseem ceeb ntawm Java tab sis ua haujlwm txawv heev. super lo lus tseem ceeb yog siv los nkag super class variables thiab txoj kev los ntawm subclass object thaum lawv overridden los ntawm subclass. kawg yog siv nyob rau hauv peb qhov chaw hauv Java nrog cov hauj lwm sib txawv.

Super lo lus tseem ceeb yog dab tsi?

super yog a lo lus tseem ceeb . Nws yog siv nyob rau hauv ib tug sub-chav kawm txoj kev txhais kom hu ib txoj kev teev nyob rau hauv lub super chav kawm. Private method of the super -Class hu tsis tau. Tsuas yog pej xeem thiab kev tiv thaiv txoj hauv kev tuaj yeem hu los ntawm super lo lus tseem ceeb . Nws kuj yog siv los ntawm chav tsev tsim kom hu cov neeg tsim tsev ntawm nws cov niam txiv chav kawm.

Peb puas tuaj yeem siv super lo lus tseem ceeb hauv txoj kev tseem ceeb?

Teb: Tsis yog! Qhov no lo lus tseem ceeb tsuas yog ua haujlwm ntawm qhov piv txwv ntawm chav kawm (ib yam khoom). Txoj kev tseem ceeb yog static nws tsis yog ib yam khoom tshwj xeeb. Super txoj kev tuaj yeem raug hu tsuas yog nyob rau hauv ib tug constructor hu rau tus constructor ntawm nws super chav kawm thiab nws yuav tsum nyob hauv thawj kab.

Pom zoo: