题目内容

以下哪些代码块能够编译通过?()

A. class Fruit { }public class Orange extends Fruit {public static void main(String[]args){Fruit f=new Fruit();Orange o=f;}};
B. class Fruit {}public class Orange extends Fruit {public static void main(String[]args){Orange o=new Orange();Fruit f=o;}};
C. interface Fruit {}public class Apple implements Fruit {public static void main(String[]args){Fruit f=new Fruit();Apple a=f;}};
D. interface Fruit {}public class Apple implements Fruit {public static void main(String []args){Apple a=new Apple();Fruit f=a;}};
E. interface Fruit {}class Apple implements Fruit {}class Orange implements Fruit {}public class MyFruit {public static void main(String []args){Orange o=new Orange();Fruit f=o;Apple a=f;}}

查看答案
更多问题

下面哪些是合法的语句(以下Panel、Applet和Frame类来自于java.awt包,请查阅相关的JavaDoc文档来了解它们是否有继承关系)?()

A. Object o = new String("abcd");
Boolean b = true;
C. Panel p = new Frame();
D. Applet a = new Panel();
E. Panel p = new Applet();

请将以下程序补充完整。_______ class C {abstract void callme();void metoo {System.out.println(“类C的metoo()方法”);}}class D_______C {void callme() {System.out.println(“重载C类的callme()方法”);}}public class Abstract {public static void main(String args[]){}C c=__________D();c.callme();c.metoo();}}

继承有哪些优点和缺点?

方法覆盖必须满足哪些规则?

答案查题题库