niusouti.com

单选题1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()A0B3C4D5EThe code will not compile.

题目
单选题
1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()
A

 0

B

 3

C

 4

D

 5

E

 The code will not compile.


相似考题
更多“单选题1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()A  0B  3C  4D  5E  The code will not compile.”相关问题
  • 第1题:

    public class test (   public static void main(string args) {   int 1= 0;   while (i) {   if (i==4) {   break;  }   ++i;  }   }   )   What is the value of i at line 10?()

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

    正确答案:E

  • 第2题:

    1. public class Test { 2. public static String output =””; 3.  4. public static void foo(int i) { 5. try { 6. if(i==1) { 7. throw new Exception(); 8. } 9. output += “1”; 10. } 11. catch(Exception e) { 12. output += “2”; 13. return; 14. } 15. finally { 16. output += “3”;17. } 18. output += “4”; 19. } 20.  21. public static void main(String args[]) { 22. foo(0); 23. foo(1); 24.  25. }26. } What is the value of the variable output at line 23?()


    正确答案:13423

  • 第3题:

    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

  • 第4题:

    1. interface foo {  2. int k = 0;  3. } 4.    5. public class test implements Foo (  6. public static void main(String args[]) (  7. int i;  8. Test test = new test ();  9. i= test.k;  10.i= Test.k;  11.i= Foo.k;  12.)  13.)  14.        What is the result?()  

    • A、 Compilation succeeds.
    • B、 An error at line 2 causes compilation to fail.
    • C、 An error at line 9 causes compilation to fail.
    • D、 An error at line 10 causes compilation to fail.
    • E、 An error at line 11 causes compilation to fail.

    正确答案:A

  • 第5题:

    1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()

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

    正确答案:E

  • 第6题:

    单选题
    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.


    正确答案: D
    解析: 暂无解析

  • 第7题:

    单选题
    public class test (   public static void main(string args) {   int 1= 0;   while (i) {   if (i==4) {   break;  }   ++i;  }   }   )   What is the value of i at line 10?()
    A

     0

    B

     3

    C

     4

    D

     5

    E

     The code will not compile.


    正确答案: E
    解析: 暂无解析

  • 第8题:

    单选题
    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.


    正确答案: D
    解析: 暂无解析

  • 第9题:

    单选题
    1. class A implements runable (   2. int i;   3. public void run () (   4. try (   5. thread.sleep(5000);   6. i= 10;   7. ) catch(InterruptedException e) {}   8. )   9. )   10.   11. public class Test {   12. public static void main (string args) (   13. try (   14. A a = new A ();   15. Thread t = new Thread (a);  16. t.start();  17.   18. int j= a.i;   19.   20. ) catch (Exception e) {}   21. )   22. )   Which statement al line 17 will ensure that j=10 at line 19?()
    A

     a.wait();

    B

     t.wait();

    C

     t.join();

    D

     t.yield();

    E

     t.notify();

    F

     a.notify();

    G

     t.interrupt();


    正确答案: D
    解析: 暂无解析

  • 第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.


    正确答案: C
    解析: 暂无解析

  • 第11题:

    单选题
    1.public class test (  2.public static void main (String args[])    {  3.int  i = 0xFFFFFFF1;  4.int  j = ~i;  5.    6.}  7.)    What is the decimal value of j at line 5?()
    A

     0

    B

     1

    C

     14

    D

     –15

    E

     An error at line 3 causes compilation to fail.

    F

     An error at line 4 causes compilation to fail.


    正确答案: B
    解析: 暂无解析

  • 第12题:

    单选题
    1. package foo; 2.  3. import java.util.Vector; 4.  5. protected class MyVector Vector { 6. init i = 1; 7. public MyVector() { 8. i = 2; 9. } 10. } 11.  12. public class MyNewVector extends MyVector { 13. public MyNewVector() { 14. i = 4; 15. } 16. public static void main(String args[]) { 17. MyVector v = new MyNewVector(); 18. } 19. } What is the result?()
    A

     Compilation succeeds.

    B

     Compilation fails because of an error at line 5.

    C

     Compilation fails because of an error at line 6.

    D

     Compilation fails because of an error at line 14.

    E

     Compilation fails because of an error at line 17.


    正确答案: A
    解析: 暂无解析

  • 第13题:

    1. package foo;  2.    3. import java.util.Vector;  4.    5. private class MyVector extends Vector {  6. int i = 1;  7. public MyVector()  {  8. i = 2;  9.    }  10. }  11.    12. public class MyNewVector extends MyVector {  13. public MyNewVector ()  {  14. i = 4;  15. }  16. public static void main (String args [])  {  17. MyVector v = new MyNewVector();  18.   }  19. }     The file MyNewVector.java is shown in the exhibit.  What is the result?()  

    • A、 Compilation will succeed.
    • B、 Compilation will fail at line 5.
    • C、 Compilation will fail at line 6.
    • D、 Compilation will fail at line 14.
    • E、 Compilation will fail at line 17.

    正确答案:B

  • 第14题:

    1. class A {  2. public String toString ()  {  3. return “4”;  4. }  5. }  6. class B extends A {  7. public String toString ()   {  8. return super.toString()  + “3”;  9. }  10. }  11. public class Test {  12.   public static void main(String[]args)  {  13.      System.out.printIn(new B());  14.      }  15. }    What is the result?()  

    • A、 Compilation succeeds and 4 is printed.
    • B、 Compilation succeeds and 43 is printed.
    • C、 An error on line 9 causes compilation to fail.
    • D、 An error on line 14 causes compilation to fail.
    • E、 Compilation succeeds but an exception is thrown at line 9.

    正确答案:B

  • 第15题:

    1.public class test (  2.public static void main (String args[])    {  3.int  i = 0xFFFFFFF1;  4.int  j = ~i;  5.    6.}  7.)    What is the decimal value of j at line 5?()  

    • A、 0
    • B、 1
    • C、 14
    • D、 –15
    • E、 An error at line 3 causes compilation to fail.
    • F、 An error at line 4 causes compilation to fail.

    正确答案:C

  • 第16题:

    1. public class Boxer1 {  2. Integer i;  3. int x;  4. public Boxer1(int y) {  5. x=i+y;  6. System.out.println(x);  7. }  8. public static void main(String[] args) {  9. new Boxer1(new Integer(4));  10. }  11. }  What is the result?() 

    • A、 The value “4” is printed at the command line.
    • B、 Compilation fails because of an error in line 5.
    • C、 Compilation fails because of an error in line 9.
    • D、 A NullPointerException occurs at runtime.
    • E、 A NumberFormatException occurs at runtime.
    • F、 An IllegalStateException occurs at runtime.

    正确答案:D

  • 第17题:

    1. package foo; 2.  3. import java.util.Vector; 4.  5. protected class MyVector Vector { 6. init i = 1; 7. public MyVector() { 8. i = 2; 9. } 10. } 11.  12. public class MyNewVector extends MyVector { 13. public MyNewVector() { 14. i = 4; 15. } 16. public static void main(String args[]) { 17. MyVector v = new MyNewVector(); 18. } 19. } What is the result?()  

    • A、 Compilation succeeds.
    • B、 Compilation fails because of an error at line 5.
    • C、 Compilation fails because of an error at line 6.
    • D、 Compilation fails because of an error at line 14.
    • E、 Compilation fails because of an error at line 17.

    正确答案:B

  • 第18题:

    单选题
    1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()
    A

     0

    B

     3

    C

     4

    D

     5

    E

     The code will not compile.


    正确答案: E
    解析: 暂无解析

  • 第19题:

    单选题
    1. class A {  2. public String toString ()  {  3. return “4”;  4. }  5. }  6. class B extends A {  7. public String toString ()   {  8. return super.toString()  + “3”;  9. }  10. }  11. public class Test {  12.   public static void main(String[]args)  {  13.      System.out.printIn(new B());  14.      }  15. }    What is the result?()
    A

     Compilation succeeds and 4 is printed.

    B

     Compilation succeeds and 43 is printed.

    C

     An error on line 9 causes compilation to fail.

    D

     An error on line 14 causes compilation to fail.

    E

     Compilation succeeds but an exception is thrown at line 9.


    正确答案: C
    解析: 暂无解析

  • 第20题:

    单选题
    1. public class SimpleCalc {  2. public int value;  3. public void calculate() { value += 7; }  4. } And:  1. public class MultiCalc extends SimpleCalc {  2. public void calculate() { value -= 3; }  3. public void calculate(int multiplier) {  4. calculate();  5. super.calculate();  6. value *=multiplier;  7. }  8. public static void main(String[] args) {  9. MultiCalc calculator = new MultiCalc();  10. calculator.calculate(2);  11. System.out.println(”Value is: “+ calculator.value);  12. }  13. }  What is the result?()
    A

     Value is: 8

    B

     Compilation fails.

    C

     Value is: 12

    D

     Value is: -12

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


    正确答案: A
    解析: 暂无解析

  • 第21题:

    单选题
    1. public class Boxer1 {  2. Integer i;  3. int x;  4. public Boxer1(int y) {  5. x=i+y;  6. System.out.println(x);  7. }  8. public static void main(String[] args) {  9. new Boxer1(new Integer(4));  10. }  11. }  What is the result?()
    A

     The value “4” is printed at the command line.

    B

     Compilation fails because of an error in line 5.

    C

     Compilation fails because of an error in line 9.

    D

     A NullPointerException occurs at runtime.

    E

     A NumberFormatException occurs at runtime.

    F

     An IllegalStateException occurs at runtime.


    正确答案: E
    解析: 暂无解析

  • 第22题:

    单选题
    1. package foo;  2.    3. import java.util.Vector;  4.    5. private class MyVector extends Vector {  6. int i = 1;  7. public MyVector()  {  8. i = 2;  9.    }  10. }  11.    12. public class MyNewVector extends MyVector {  13. public MyNewVector ()  {  14. i = 4;  15. }  16. public static void main (String args [])  {  17. MyVector v = new MyNewVector();  18.   }  19. }     The file MyNewVector.java is shown in the exhibit.  What is the result?()
    A

     Compilation will succeed.

    B

     Compilation will fail at line 5.

    C

     Compilation will fail at line 6.

    D

     Compilation will fail at line 14.

    E

     Compilation will fail at line 17.


    正确答案: B
    解析: 暂无解析

  • 第23题:

    单选题
    1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?()
    A

     Line 4 of class Target can be changed to return i++;

    B

     Line 2 of class Target can be changed to private int i = 1;

    C

     Line 3 of class Target can be changed to private int addOne() {

    D

     Line 2 of class Target can be changed to private Integer i = 0;


    正确答案: C
    解析: 暂无解析

  • 第24题:

    单选题
    1. interface foo {  2. int k = 0;  3. } 4.    5. public class test implements Foo (  6. public static void main(String args[]) (  7. int i;  8. Test test = new test ();  9. i= test.k;  10.i= Test.k;  11.i= Foo.k;  12.)  13.)  14.        What is the result?()
    A

     Compilation succeeds.

    B

     An error at line 2 causes compilation to fail.

    C

     An error at line 9 causes compilation to fail.

    D

     An error at line 10 causes compilation to fail.

    E

     An error at line 11 causes compilation to fail.


    正确答案: A
    解析: 暂无解析