单选题1.class TestSuper { 22.TestSuper(int i) { } 3. } 4.class TestSub extends TestSuper{ } 5.class TestAll { 6.public static void main (String [] args) { 7.new TestSub(); 8.} 9.} Which is true?()A  Compilation fails.B  The code runs without exception.C  An 

题目
单选题
1.class TestSuper { 22.TestSuper(int i) { } 3. } 4.class TestSub extends TestSuper{ } 5.class TestAll { 6.public static void main (String [] args) { 7.new TestSub(); 8.} 9.} Which is true?()
A

 Compilation fails.

B

 The code runs without exception.

C

 An exception is thrown at line 7.

D

 An exception is thrown at line 2.

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

public class Test {  public static void main(String [] args) {  boolean assert = true;  if(assert) {  System.out.println(”assert is true”);  }  }  } Given:  javac -source 1.3 Test.java  What is the result?() 

  • A、 Compilation fails.
  • B、 Compilation succeeds with errors.
  • C、 Compilation succeeds with warnings.
  • D、 Compilation succeeds without warnings or errors.

正确答案:C

第2题:

public class Alpha{  private static Character() ids;  public static void main( String[] args){  ids = new Character[args.length];  for (int i=0; iids[i] = new Character( args[i] );  System.out.print( ids[i] );  }  }  }   What is correct?()  

  • A、 Compilation fails.
  • B、 The code runs with no output.
  • C、 An exception is thrown at runtime.
  • D、 The code runs, outputing a concatenated list of the arguments passed to the program.

正确答案:A

第3题:

classTestSuper{22.TestSuper(inti){}3.}4.classTestSubextendsTestSuper{}5.classTestAll{6.publicstaticvoidmain(String[]args){7.newTestSub();8.}9.}Whichistrue?()

A.Compilationfails.

B.Thecoderunswithoutexception.

C.Anexceptionisthrownatline7.

D.Anexceptionisthrownatline2.


参考答案:A

第4题:

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

第5题:

public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()  

  • A、 true
  • B、 null
  • C、 false
  • D、 Compilation fails.
  • E、 The code runs with no output.
  • F、 An exception is thrown at runtime.

正确答案:A

第6题:

1.class TestSuper { 22.TestSuper(int i) { } 3. } 4.class TestSub extends TestSuper{ } 5.class TestAll { 6.public static void main (String [] args) { 7.new TestSub(); 8.} 9.} Which is true?()  

  • A、 Compilation fails.
  • B、 The code runs without exception.
  • C、 An exception is thrown at line 7.
  • D、 An exception is thrown at line 2.

正确答案:A

第7题:

1. public class X {  2. public static void main (String[]args)   {  3. int [] a = new int [1]  4. modify(a);  5. System.out.printIn(a[0]);  6. }  7.    8. public static void modify (int[] a)  {  9.   a[0] ++;  10.    } 11. }       What is the result?()

  • A、 The program runs and prints “0”
  • B、 The program runs and prints “1”
  • C、 The program runs but aborts with an exception.
  • D、 An error “possible undefined variable” at line 4 causes compilation to fail.
  • E、 An error “possible undefined variable” at line 9 causes compilation to fail.

正确答案:B

第8题:

class MyThread extends Thread {  public void run() { System.out.println(“AAA”); }  public void run(Runnable r) { System.out.println(“BBB”); }  public static void main(String[] args) {  new Thread(new MyThread()).start();  }  }   What is the result?()  

  • A、 AAA
  • B、 BBB
  • C、 Compilation fails.
  • D、 The code runs with no output.

正确答案:A

第9题:

1. public class ForBar  {  2. public static void main(String []args)   {  3.   int i = 0, j = 5;  4. tp: for (;;)  {  5. i ++;  6. for(;;)  7. if(i > --j) break tp;  8. }  9. system.out.printIn(“i = ” + i + “, j = “+ j);  10. }  11. }   What is the result?()  

  • A、 The program runs and prints “i=1, j=0”
  • B、 The program runs and prints “i=1, j=4”
  • C、 The program runs and prints “i=3, j=4”
  • D、 The program runs and prints “i=3, j=0”
  • E、 An error at line 4 causes compilation to fail.
  • F、 An error at line 7 causes compilation to fail.

正确答案:A

第10题:

1. class Pizza {  2. java.util.ArrayList toppings;  3. public final void addTopping(String topping) {  4. toppings.add(topping); 5. }  6. }  7. public class PepperoniPizza extends Pizza {  8. public void addTopping(String topping) {  9. System.out.println(”Cannot add Toppings”);  10. }  11. public static void main(String[] args) {  12. Pizza pizza = new PepperoniPizza();  13. pizza.addTopping(”Mushrooms”);  14. }  15. }  What is the result?() 

  • A、 Compilation fails.
  • B、 Cannot add Toppings
  • C、 The code runs with no output.
  • D、 A NullPointerException is thrown in Line 4.

正确答案:A

更多相关问题