niusouti.com

单选题11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code

题目
单选题
11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?()
A

 It is true that j==i.

B

 It is false that j==i.

C

 An exception is thrown at runtime.

D

 Compilation fails because of an error in line 13.


相似考题
更多“单选题11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code”相关问题
  • 第1题:

    下列程序执行后的结果是______。

    public class ex24

    {

    public static void main(String[] args)

    {

    int j=10;

    a1: for(int i=3;i>0;i--)

    {

    j-=i;

    int m=l;

    a2: while (m<j)

    {

    if (i<=m)

    continue a1;

    j/=m++;

    }

    }

    System.out.println(j);

    }

    }

    下列嵌套的循环程序执行后,结果是______。 public class ax25 { public static void main(String[] args) { int sum=0; for(int i=0;i<=5;i++) { for(int j=10;j>3*i;j--) { sum+=j*i; } } System.out.println(sum); } }

    A.136

    B.127

    C.147

    D.153


    正确答案:C

  • 第2题:

    控制台应用程序 example.java 如下:

    public class example

    {

    public static void main(String[] args)

    {

    int i=0, j=9;

    do

    {

    if(i++>--j) break;

    } while(i<4);

    System.out.println("i="+i+" and j="+j);

    }

    }


    正确答案:
      

  • 第3题:

    下列程序输出结果为( )。 public class test { public static void main (String args[]) { int a=0; outer:for(int i=0;i<2;i + +) { for(int j=0;j<2;j+ +) { if(j>i) { continue outer; } a+ +; } } System.out.println(a); } }

    A.0

    B.2

    C.3

    D.4


    正确答案:C

  • 第4题:

    下列语句执行后,i的值是( )。 public class Test { public static void main(String[ ] args) { int i =0; for(int j=10; j>5&&i<5; j-=3,i+=2) i=i+j; System.out.println(i); } }

    A.8

    B.9

    C.10

    D.12


    正确答案:D
    解析:变量i和j的初始值分别为0和10,判断结束条件j>5&&i5为true,执行i=i+j;得到i=10,再做j-=3和i+=2,分别得到i=12和j=7,判断结束条件j>5&&i5为false,停止循环,因此i的值为12,正确答案为D。

  • 第5题:

    11. public static void main(String[] args) {  12. Integer i = uew Integer(1) + new Integer(2);  13. switch(i) {  14. case 3: System.out.println(”three”); break;  15. default: System.out.println(”other”); break;  16. }  17. }  What is the result?() 

    • A、 three
    • B、 other
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error on line 12.
    • E、 Compilation fails because of an error on line 13.
    • F、 Compilation fails because of an error on line 15.

    正确答案:A

  • 第6题:

    11. public class Counter {  12. public static void main(String[] args) {  13. int numArgs = /* insert code here */;  14. }  15. }  and the command line: java Counter one fred 42 Which code, inserted at line 13, captures the number of arguments passed into the program?() 

    • A、 args.count
    • B、 args.length
    • C、 args.count()
    • D、 args.length()
    • E、 args.getLength()

    正确答案:B

  • 第7题:

    11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?() 

    • A、 It is true that j==i.
    • B、 It is false that j==i.
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error in line 13.

    正确答案:D

  • 第8题:

    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

  • 第9题:

    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()  

    • A、 The program prints “0”
    • B、 The program prints “4”
    • C、 The program prints “8”
    • D、 The program prints “12”
    • E、 The code does not complete.

    正确答案:B

  • 第10题:

    单选题
    public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()
    A

     0

    B

     1

    C

     2

    D

     Compilation fails.


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

  • 第11题:

    单选题
    11. static class A {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B”); }  16. }  17. public static void main(String[] args) {  18. new B().process();  19. }  What is the result?()
    A

     B

    B

     The code runs with no output.

    C

     Compilation fails because of an error in line 12.

    D

     Compilation fails because of an error in line 15.

    E

     Compilation fails because of an error in line 18.


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

  • 第12题:

    单选题
    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
    解析: 暂无解析

  • 第13题:

    下列程序输出结果为( )。public class test { public static void main(String args[]) { int a=0; outer: for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { if(j>i) { continue outer; } a++; } } System.out.println(a); }}

    A.0

    B.2

    C.3

    D.4


    正确答案:C

  • 第14题:

    以下程序的输出结果为( )。 public class Main { public static void main(String[] args) { int i=0, j=0, a=6; if((++i>0)||(++j>0)) a++; System.out.println( "i=" +i+", j ="+j+", a="+A; } }

    A.i=0, j=0, a=6

    B.i=1, j=1, a=7

    C.i=1, j=0, a=7

    D.i=0, j=1, a=7


    正确答案:C
    解析:因为表达式(++i>0)先进行了i自增1的运算,所以i的值不可能为0。因此答案 A和D都不对。因为表达式(++i>0)的值为“真”,对于“或”运算来说只要运算符“||”左边的值为“真”,已确定了整个表达式的值为“真”,因而不再去做“||”运算符右边的运算,所以++j的运算并未进行。因此,答案C是正确的输出结果。

  • 第15题:

    执行下面程序后,结果是 public class Testrr { public static void main(String args[]){ int i=0xFFFFFFF1; int j=-i; System.out.println("j="+j); } }

    A.j=-15

    B.j=-16

    C.j=16

    D.j=15


    正确答案:D
    解析:①负数在计算机中的表示形式是采用补码形式的。所谓补码:一般用十六位二进制来表示一个补码,二进制的第一位是符号位,剩下的十五位是数值位。如果数是正数,符号位取0,然后用本身的二进制作为这个数的数值位;如果是负数,符号位取1,然后把本身的二进制码每位取反,然后在末尾加一,便得这个数的数值位。②题目中给的inti=0xFFFFFFF1;用一个十六进制的数来表示二进制数,其二进制是1111111111110001,这样看是一个负数的补码,还原十进制,得0000000000001111,是-15。③题目中要求输出i得负数得int型,这样肯定是15。

  • 第16题:

    以下程序的运行结果为:public class test {public static void main(String args[]) {int i=0, j=2;do {i=++i;j--;} while(j>0);System.out.println(i);}}

    A. 0

    B. 1

    C. 2

    D.3


    正确答案:C

  • 第17题:

    public class Test {  public static void main(String Args[]) {  int i =1, j = 0;  switch(i) {  case 2: j +=6;  case 4: j +=1;  default: j +=2;  case 0: j +=4;  }  System.out.println(“j =” +j);  }  }  What is the result? () 

    • A、 0
    • B、 2
    • C、 4
    • D、 6
    • E、 9
    • F、 13

    正确答案:D

  • 第18题:

    11. static class A {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B”); }  16. }  17. public static void main(String[] args) {  18. new B().process();  19. }  What is the result?() 

    • A、 B
    • B、 The code runs with no output.
    • C、 Compilation fails because of an error in line 12.
    • D、 Compilation fails because of an error in line 15.
    • E、 Compilation fails because of an error in line 18.

    正确答案:A

  • 第19题:

     public class Foo {   public static void main (String []args) {   int i = 1;   int j = i++;   if ((i>++j) && (i++ ==j))  {           i +=j;          }        }      }   What is the final value of i?()  

    • A、 1
    • B、 2
    • C、 3
    • D、 4
    • E、 5

    正确答案:B

  • 第20题:

    public class Test {  public int aMethod() {  static int i = 0;  i++;  return i;  }  public static void main (String args[]) {  Test test = new Test();  test.aMethod();  int j = test.aMethod();  System.out.println(j);  }  }  What is the result?()  

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

    正确答案:D

  • 第21题:

    单选题
    public class Test {  public static void main(String Args[]) {  int i =1, j = 0;  switch(i) {  case 2: j +=6;  case 4: j +=1;  default: j +=2;  case 0: j +=4;  }  System.out.println(“j =” +j);  }  }  What is the result? ()
    A

     0

    B

     2

    C

     4

    D

     6

    E

     9

    F

     13


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

  • 第22题:

    单选题
    11. public static void main(String[] args) {  12. Integer i = uew Integer(1) + new Integer(2);  13. switch(i) {  14. case 3: System.out.println(”three”); break;  15. default: System.out.println(”other”); break;  16. }  17. }  What is the result?()
    A

     three

    B

     other

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error on line 12.

    E

     Compilation fails because of an error on line 13.

    F

     Compilation fails because of an error on line 15.


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

  • 第23题:

    单选题
    11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?()
    A

     It is true that j==i.

    B

     It is false that j==i.

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error in line 13.


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

  • 第24题:

    单选题
    public class test (      private static int j = 0;  private static boolean methodB(int k) (  j += k;  return true;  )  public static void methodA(int  i)(  boolean b:     b = i < 10 | methodB (4);  b = i < 10 || methodB (8);  )  public static void main (String args[])(   methodA (0);  system.out.printIn(j);  )  )   What is the result?()
    A

     The program prints “0”

    B

     The program prints “4”

    C

     The program prints “8”

    D

     The program prints “12”

    E

     The code does not complete.


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