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、 2B、 4C、 8D、 16E、 The code will not co

题目

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.

相似考题
更多“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、 2B、 4C、 8D、 16E、 The code will not compi”相关问题
  • 第1题:

    下面语句执行后,i的值是______。 public class Test11 { 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.10

    B.9

    C.8

    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。

  • 第2题:

    下列程序执行后,j的值是( )。 public class Testggg{ public static void main(String args[]) { int j=1; for(int i=7;i>0;i-=2) j*=2; System.out.println(j); } }

    A.15

    B.1

    C.32

    D.16


    正确答案:D

  • 第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题:

    下列程序执行后,j的值是( )。 public class Test { public static void main(String args[]) { int j=1; for(int i=7;i>0;i-=2) j*=2; System.out.println(j); } }

    A.15

    B.1

    C.32

    D.16


    正确答案:D
    解析:利用for循环语句求2的4次幂。一般情况下迭代部分都用i++或i--,但在这里用的是i-=2,需要留意。

  • 第5题:

    下面程序的输出结果是( )。 public class Sun { public static void main(String args[]) { int[] a={1,2,3,4); int j=1,s=0; for(int i=3;i>=0;i--) { s=s+a[i]*j; j=j*10; } System.out.println(s); } }

    A.1234

    B.21

    C.43

    D.4321


    正确答案:A
    解析:本题考查对for循环语句和数组的理解。for语句中步长为-1即每循环一次,循环变量i的值减1,数组进行反运算,即a[i]取值4、3、2、1。故本题答案是A。

  • 第6题:

    下列语句执行后,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。

  • 第7题:

    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

  • 第8题:

    public class ForBar {   public static void main(String args) {   int i = 0, j = 5;   tp: for (;;) {   i ++;   for(;;)   if(i > --j) break tp;   }   system.out.printIn(“i = ” + i + “, j = “+ j);   }   }   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

  • 第9题:

    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

  • 第10题:

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

  • 第11题:

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


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

  • 第12题:

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

  • 第13题:

    下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int j=2,i=5; while (j<i--) j++; System.out.println(j);} }

    A.2

    B.3

    C.4

    D.5


    正确答案:C
    解析:循环时,首先判断结束条件,25,然后i=4,j=3,继续循环,i=3,j=4,结果条件ji为假,退出循环,因此j=4。所以选C。

  • 第14题:

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

    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

  • 第15题:

    控制台应用程序 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);

    }

    }


    正确答案:
      

  • 第16题:

    下列程序输出结果为( )。 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

  • 第17题:

    执行下面程序后,结果是 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。

  • 第18题:

    以下程序的运行结果为: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

  • 第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.printIn(j);   ]  }   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”

    正确答案:D

  • 第21题:

    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

  • 第22题:

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

  • 第23题:

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