so sánh interface và abstract class trong java

Upload: tran-huu-thang

Post on 05-Apr-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 So Snh Interface v Abstract Class trong java

    1/1

    interface abstract class

    interface - 1 interface c thextends t 1 haynhiu interface khc, cch nhau bi duphy .

    - ko th implementst interface khc

    - 1 interface ko thextends t 1 abstractclass

    abstract class - 1 abstract class cth implementsnhiu interface.

    - 1 abstract class cth extends t 1abstract khc

    class - 1 class c thimplements 1 haynhiu interface.

    - Nhiu class c thimplements cng 1interface.

    - Khi 1 classimplements 1interface th class bt buc phi ci tht cc method ctrong interface

    - 1 class ch c thextends t 1abstract class .

    - Khi 1 class extends1 abstract class thclass c th cit ht hoc ch cit 1 vi method ctrong abstract class.

    method - Cc method khaibo trong interfaceko c khai bophn thn .

    - Cc method ko khaibo l abstractnhng c coi lcc method abstract.

    - Cc method tronginterface ch ckhai bo l public.

    - Cc method khaibo trong abstractclass c th nhngha phn thn ,hoc trng phnthn.

    - Cc method trongabstract class c thc khai bo l :public , protected ,final.

    - Nu trong abstractclass khai bomethod abstract thcc class extends tn phi ci tmethod abstract ny.

    Variable