有以下代码,请选择一个正确的答案替换其中的注释行,使之不会发生错误。( )class A{ A(int i) { }}public class B extends A{ B() { //******** } public static void main(String args[]) { B b=new B(); }}
A: this(100);
B: super(100);
C: super();
D: this();
A: this(100);
B: super(100);
C: super();
D: this();
举一反三
- 对于下列代码,下列哪个叙述是正确的? class A { public int i=0; A(int m) { i = 1; } } public class B extends A { B(int m) { i = 2; } public static void main(String args[]){ B b = new B(100); System.out.println(b.i); //【代码】 } }
- 给出以下代码,请问插入以下哪些语句可以使程序编译通过?( )class Base{public Base(int i){}}public class Example extend Base{public static void main (String arg[]){Example e = new Example(10);}Example(int i){Super(i);}Exanple(String s, int i){this(i);//插入代码处}}请选择一个正确答案: A: Example d = new Example(); B: Super(); C: This(“Hello”,10); D: Base b = ne Base(10);
- 下列ABCD注释标注的哪行代码有错public class Demo { public static void main(String args[]) { System.out.println("Java"); system.out.println("hello"); System.out.println("你好"); } } A: public class Demo B: public static void main(String args[]) C: system.out.println("ok"); D: System.out.println("您好");
- ( File 类)有如下代码: public class TestFile{ public static void main(String args[]){ File file = new File(“chp1 1 /corejava.txt”); } } 请选择一个正确答案:
- 阅读下列程序,请写出该程序的输出结果。 class B{ int b; B(int x){b=x;System.out.println("b="+b); } } class A extends B{ int a; A(int x,int y){ super(x); a=y; System.out.println("b="+b+",a="+a); } } public class a32{ public static void main(String[]args){ A obj=new A(1,2); } }