A.接口中只能包含抽象方法和常量 B.一個(gè)類可以實(shí)現(xiàn)多個(gè)接口 C.接口不能被繼承 D.類實(shí)現(xiàn)接口時(shí)必須實(shí)現(xiàn)其中的方法
class BitStuff { BitStuff go() { System.out.print("bits "); return this; } } class MoreBits extends BitStuff { MoreBits go() { System.out.print("more "); return this; } public static void main(String [] args) { BitStuff [] bs = {new BitStuff(), new MoreBits()}; for( BitStuff b : bs) b.go(); } } 結(jié)果為:()
A.bits bits B.bits more C.more more D.編譯失敗
class Mineral { static String shiny() { return "1"; } } class Granite extends Mineral { public static void main(String [] args) { String s = shiny() + getShiny(); s = s + super.shiny(); System.out.println(s); } static String getShiny() { return shiny(); } } 結(jié)果為:()
A.3 B.12 C.111 D.編譯失敗