单选题class super (  public int I = 0;  public super (string text) (  I = 1  )  )  public class sub extends super (  public sub (string text)   ( i= 2  )  public static void main (straing args[])   (  sub sub = new sub (“Hello”);  system.out. PrintIn(sub.i);

题目
单选题
class super (  public int I = 0;  public super (string text) (  I = 1  )  )  public class sub extends super (  public sub (string text)   ( i= 2  )  public static void main (straing args[])   (  sub sub = new sub (“Hello”);  system.out. PrintIn(sub.i);  )    )   What is the result?()
A

 Compilation will fail.

B

 Compilation will succeed and the program will print “0”

C

 Compilation will succeed and the program will print “1”

D

 Compilation will succeed and the program will print “2”

参考答案和解析
正确答案: A
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

 class Super {  public Integer getLenght() { return new Integer(4); } }  public class Sub extends Super {  public Long GetLenght() { return new Long(5); }  public static void main(String[] args) { Super sooper = new Super();  Sub sub = new Sub();  System.out.println(  sooper.getLenght().toString() + “,” +  sub.getLenght().toString() ); } }  What is the output?()  

  • A、 4,4
  • B、 4,5
  • C、 5,4
  • D、 5,5
  • E、 Compilation fails.

正确答案:A

第2题:

class super {  public int getLength()  {return 4;}  }  public class Sub extends Super {  public long getLength() {return 5;}  public static void main (String[]args)  {  super sooper = new Super ();  Sub sub = new Sub();  System.out.printIn(  sooper.getLength()+ “,” + sub.getLength()   };  }  What is the output?()  

  • A、 4, 4
  • B、 4, 5
  • C、 5, 4
  • D、 5, 5
  • E、 The code will not compile.

正确答案:E

第3题:

设有类定义如下:

class Base{

public Base(int i){}

}

public class MyOver extends Base{

public static void main(String arg[]){

MyOver m = new MyOver(10);

}

MyOver(int i){

super(i);

}

MyOver(String s, int i){

this(i);

//Here

}

}

以下哪条语句可以安排在//Here处 ?

A.MyOver m = new MyOver();

B.super();

C.this("Hello",10);

D.Base b = new Base(10);


正确答案:D

第4题:

Public class test (    Public static void stringReplace (String text) (    Text = text.replace („j„ , „i„);    )      public static void bufferReplace (StringBuffer text) (    text = text.append (“C”)   )      public static void main (String args ){  String textString = new String (“java”);    StringBuffer text BufferString = new StringBuffer (“java”);      stringReplace (textString);    BufferReplace (textBuffer);      System.out.printIn (textString + textBuffer);    }   )   What is the output?()


正确答案:javajavaC

第5题:

class Super {  public int i = 0;  public Super(String text) {  i = 1; }  }  public class Sub extends Super {  public Sub(String text) {  i = 2;  }   public static void main(String args[]) {  Sub sub = new Sub(“Hello”);  System.out.println(sub.i);  }  }  What is the result?()  

  • A、 0
  • B、 1
  • C、 2
  • D、 Compilation fails.

正确答案:C

第6题:

class Super {  public int getLenght( ) { return 4; }  }  public class Sub extends Super {  public long getLenght( ) { return 5; }  public static void main(String[] args) {  Super sooper = new Super( );  Sub sub = new Sub( );  System.out.println(  sooper.getLenght( ) + “,” + sub.getLenght( ) );  }  } What is the output?()

  • A、 Just after line 13.
  • B、 Just after line 14.
  • C、 Just after line 15.
  • D、 Just after line 16 (that is, as the method returns).

正确答案:C

第7题:

class A {  public A() {  System.out.println(“hello from a”);  }  }  class B extends A {  public B () {  System.out.println(“hello from b”);  super();  }  }  public class Test {  public static void main(String args[]) {  A a = new B();  }  }   What is the result when main is executed?()  

  • A、 Compilation fails.
  • B、 hello from a
  • C、 hello from b
  • D、 hello from b hello from a
  • E、 hello from a hello from b

正确答案:A

第8题:

( 30 )在程序的下划线处应填入的选项是

public class Test _________{

public static void main(String args[]){

Test t = new Test();

Thread tt = new Thread(t);

tt.start();

}

public void run(){

for(int i=0;i<5;i++){

system.out.println( " i= " +i);

}

}

}

A ) implements Runnable

B ) extends Thread

C ) implements Thread

D ) extends Runnable


正确答案:A

第9题:

class Super { public int getLenght() { return 4; } } public class Sub extends Super { public long getLenght() { return 5; } public static void main(String[] args) {Super sooper = new Super(); Sub sub = new Sub(); System.out.println( sooper.getLenght() + “,” + sub.getLenght() ); } } What is the output? ()

  • A、 4,4
  • B、 4,5
  • C、 5,4
  • D、 5,5
  • E、 Compilation fails.

正确答案:E

第10题:

public class Test {  public static void leftshift(int i, int j) {  i<<=j;  }  public static void main(String args[])  {  int i = 4, j = 2;  leftshift(i, j);   System.out.printIn(i); }  }     What is the result?()  

  • A、 2
  • B、 4
  • C、 8
  • D、 16
  • E、 The code will not compile.

正确答案:B

更多相关问题