以下代码调试结果 class Base {} class Sub extends...Sub s = (Sub) b; } }
以下代码调试结果 class Base {} class Sub extends...Sub s = (Sub) b; } }
以下代码调试结果 class Base {} class Sub extends Base {} public class CEx{ public static void main(String argv[]){ Base b = new Base(); Sub s = (Sub) b; } }
以下代码调试结果 class Base {} class Sub extends Base {} public class CEx{ public static void main(String argv[]){ Base b = new Base(); Sub s = (Sub) b; } }
给定如下代码: class Alpha { static String s = " "; protected Alpha() { s += "alpha "; } } class SubAlpha extends Alpha { private SubAlpha() { s += "sub "; } } public class SubSubAlpha extends Alpha { private SubSubAlpha() { s += "subsub "; } public static void main(String[] args) { new SubSubAlpha(); System.out.println(s); } } 运行结果为?(). A: subsub B: sub subsub C: alpha subsub D: alpha sub subsub
给定如下代码: class Alpha { static String s = " "; protected Alpha() { s += "alpha "; } } class SubAlpha extends Alpha { private SubAlpha() { s += "sub "; } } public class SubSubAlpha extends Alpha { private SubSubAlpha() { s += "subsub "; } public static void main(String[] args) { new SubSubAlpha(); System.out.println(s); } } 运行结果为?(). A: subsub B: sub subsub C: alpha subsub D: alpha sub subsub
中国大学MOOC: applet要extends JApplet或extends Applet
中国大学MOOC: applet要extends JApplet或extends Applet
class Employee; class Manager extends Employee; class Director extends Employee;
class Employee; class Manager extends Employee; class Director extends Employee;
Which two, inserted at line 11, will allow the code to compile?() A: public class MinMax<?>{ B: public class MinMax<? extends Number>{ C: public class MinMax<N extends Object>{ D: public class MinMax<N extends Number>{ E: public class MinMax<? extends Object>{ F: public class MinMax<N extends Integer>{
Which two, inserted at line 11, will allow the code to compile?() A: public class MinMax<?>{ B: public class MinMax<? extends Number>{ C: public class MinMax<N extends Object>{ D: public class MinMax<N extends Number>{ E: public class MinMax<? extends Object>{ F: public class MinMax<N extends Integer>{
class A class B extends A class C extends A 则以下语句能通过编译的是( )
class A class B extends A class C extends A 则以下语句能通过编译的是( )
以下()不是Java中的合法标识符。 A: extends B: extend C: exte$nd D: EXTENDS
以下()不是Java中的合法标识符。 A: extends B: extend C: exte$nd D: EXTENDS
以下代码能否通过编译,如果通过编译,运行“java Sub”时得到什么打印结果? abstract class Base{ abstract public void method1();abstract public void method2();}public class Sub extends Base{public static void main(String args[]){Base a = new Sub();a.method1();} public void method1(){System.out.println("method1");}} A: 运行时打印“method1”。 B: 编译时出错:Sub类必须为抽象类。 C: 运行时出错:Sub类不能被实例化。 D: 编译时出错:main()方法中的变量a必须声明为Sub类型。
以下代码能否通过编译,如果通过编译,运行“java Sub”时得到什么打印结果? abstract class Base{ abstract public void method1();abstract public void method2();}public class Sub extends Base{public static void main(String args[]){Base a = new Sub();a.method1();} public void method1(){System.out.println("method1");}} A: 运行时打印“method1”。 B: 编译时出错:Sub类必须为抽象类。 C: 运行时出错:Sub类不能被实例化。 D: 编译时出错:main()方法中的变量a必须声明为Sub类型。
Java中,类继承的语法格式是() A: class子类名extends父类名{} B: class父类名extends父类名{} C: class子类名extends子类名{} D: class父类名extends子类名{}
Java中,类继承的语法格式是() A: class子类名extends父类名{} B: class父类名extends父类名{} C: class子类名extends子类名{} D: class父类名extends子类名{}