单选题public class Alpha1 {  public static void main( String[] args ) {  boolean flag; int i=0;  do {  flag = false;  System.out.println( i++ );  flag = i < 10;  continue;  } while ( (flag)? true:false );  }  }  What is the result?()A000000000B0123456789CCom

题目
单选题
public class Alpha1 {  public static void main( String[] args ) {  boolean flag; int i=0;  do {  flag = false;  System.out.println( i++ );  flag = i < 10;  continue;  } while ( (flag)? true:false );  }  }  What is the result?()
A

 000000000

B

 0123456789

C

 Compilation fails.

D

 The code runs with no output.

E

 The code enters an infinite loop.

F

 An exception is thrown at runtime.


相似考题
更多“单选题public class Alpha1 {  public static void main( String[] args ) {  boolean flag; int i=0;  do {  flag = false;  System.out.println( i++ );  flag = i  10;  continue;  } while ( (flag)? true:false );  }  }  What is the result?()A  000000000B  0123456789C”相关问题
  • 第1题:

    publicclassAlpha1{publicstaticvoidmain(String[]args){booleanflag;inti=0;do{flag=false;System.out.println(i++);flag=i<10;continue;}while((flag)?true:false);}}Whatistheresult?()

    A.000000000

    B.0123456789

    C.Compilationfails.

    D.Thecoderunswithnooutput.

    E.Thecodeentersaninfiniteloop.

    F.Anexceptionisthrownatruntime.


    参考答案:B

  • 第2题:

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

    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

  • 第3题:

    本题定义了一个长度为l0的boolean型数组,并给数组元素赋值,要求如果数组元素下标为奇数,则数组元素值 为false,否则为true。 public class javal{ pubhc static void main(String[]args){ boolean b[]= ; for(int i=0;i<10;i++){ if( ) b[i]=false; else ; } for(int i=0;i<10;i++) System.Out.print("bE"+i+"]="+b[i]+","); } }


    正确答案:
    第1处:new boolean[10]
    第2处:i%2 1=0
    第3处:b[i]=true
    【解析】第1处定义了一个长度为10的boolean型数组;第2处判断数组元素下标是否为奇数。第3处不为奇数的情况下数组元素值设为true。

  • 第4题:

    以下程序的运行结果为

    class Prob10 {

    static boolean b1;

    public static void main(String [] args) {

    int i1 = 11;

    double f1=1.3;

    do {

    b1 = (f1 >4、&& (i1--< 10);

    f1 += 1.0;

    } while (!b 1、;

    System.out.println(b1 + "," + i1 + "," + f 1、;

    }

    }

    A. false,9,4.3

    B. true,11,1.3

    C. false,8,1.3

    D. true,8,7.3


    正确答案:D


  • 第5题:

    现有:  class Waiting implements Runnable  {       boolean flag=false;  public  synchronized void run()  {       if  (flag)  {       flag=false;  System.out.print ("1");  try  {  this.wait();  )  catch  (Exception e)  {  }       System.out.print ("2");       }  else  {       flag=true;  System.out.print ("3");  try{Thread.sleep (2000); } catch(Exception e)  {}      System.out.print ("4");       notify();       }       }  public static void main (String  []  args)  {       Waiting w=new Waiting();       new Thread (w) .start();       new Thread (w) .start();       }       }  以下哪两项是正确的?()    

    • A、代码输出l 3 4
    • B、代码输出3 4 1
    • C、代码输出l 2 3 4
    • D、代码输出1 3 4 2
    • E、代码运行完毕
    • F、代码不会完成

    正确答案:B,F

  • 第6题:

    public class Alpha1 {  public static void main( String[] args ) {  boolean flag; int i=0;  do {  flag = false;  System.out.println( i++ );  flag = i < 10;  continue;  } while ( (flag)? true:false );  }  }  What is the result?()  

    • A、 000000000
    • B、 0123456789
    • C、 Compilation fails.
    • D、 The code runs with no output.
    • E、 The code enters an infinite loop.
    • F、 An exception is thrown at runtime.

    正确答案:B

  • 第7题:

    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

  • 第8题:

    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

  • 第9题:

    多选题
    class Waiting implements Runnable {  boolean flag = false;  public synchronized void run() {  if (flag) {  flag = false;  System.out.print("1 ");  try { this.wait(); } catch (Exception e) { }  System.out.print("2 ");  }  else {  flag = true;  System.out.print("3 ");  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("4 ");  notify();  }  }  public static void main(String [] args) {  Waiting w = new Waiting();  new Thread(w).start();  new Thread(w).start ();  }  }  以下哪两项是正确的?()
    A

    代码输出 1 3 4

    B

    代码输出 3 4 1

    C

    代码输出 1 2 3 4

    D

    代码不会完成


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

  • 第10题:

    单选题
    public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()
    A

     ABDCBDCB

    B

     ABCDABCD

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


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

  • 第11题:

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

  • 第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[]){ for(int i=0; i<3;i++){ if(i<2) continue; System.out.println(i); } } }

    A.0

    B.1

    C.2

    D.3


    正确答案:C
    解析:本题考查简单的Java控制语句。题目非常简单,但还是应该细心。这里应注意continue语句。continue语句是跳过循环体中下面尚未执行的语句,回到循环体的开始继续下一轮的循环。当然,在下一轮循环开始前,要先进行终止条件的判断,以决定是否继续循环。对于for语句,在进行终止条件的判断前,还要先执行迭代语句。题目所给程序中,当i=0和i=1时,都会执行continue语句,而不会执行System.out.println(i)语句,只有当i=2时才执行System.out.println(i)语句,输出为2,选项C正确。

  • 第14题:

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

  • 第15题:

    有如下代码段 public class OperatorAndExceptions { public static void main(String args[]) { int i=10,j=15; System.out.println(i==j); String s1=new String("how are you!"); String s2=new String("how are you!"); System.out.println(s1==s2); } } 其输出为( )。

    A.true false

    B.true true

    C.false true

    D.false false


    正确答案:D
    解析:本题考查比较运算符=的使用。比较运算符不仅可以用于基本数据类型的数据之间的比较,还可以用于复合数据类型的数据之间的比较。题中整型数i和j的值不同,故其==比较的结果为false。s1和s2的值虽然都是“howareyou!”,但是由于它们是不同的对象,因此运算后的结果为false。如果需要比较两个对象的值是否相同,则可以调用equals()方法。

  • 第16题:

    现有:  class  Ifs  {  public  static void main (String  []  args)  {      boolean state=false;      int i=2;  if( (++i>2)  &&  (state=true))     i++;  if( (++i>4)  l l  (state=false))      i++;  System.out .println (i);     }     } 结果为:()     

    • A、  6
    • B、  5
    • C、  4
    • D、编译失败

    正确答案:A

  • 第17题:

    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

  • 第18题:

    public class Delta {  static boolean foo(char c) {  System.out.print(c);  return true;  }  public static void main( String[] argv ) {  int i =0;  for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){  i++ ;  foo(‘D’);  }  }  }  What is the result?()  

    • A、 ABDCBDCB
    • B、 ABCDABCD
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第19题:

    class Waiting implements Runnable {  boolean flag = false;  public synchronized void run() {  if (flag) {  flag = false;  System.out.print("1 ");  try { this.wait(); } catch (Exception e) { }  System.out.print("2 ");  }  else {  flag = true;  System.out.print("3 ");  try { Thread.sleep(2000); } catch (Exception e) { }  System.out.print("4 ");  notify();  }  }  public static void main(String [] args) {  Waiting w = new Waiting();  new Thread(w).start();  new Thread(w).start ();  }  }  以下哪两项是正确的?() 

    • A、代码输出 1 3 4
    • B、代码输出 3 4 1
    • C、代码输出 1 2 3 4
    • D、代码不会完成

    正确答案:A,B

  • 第20题:

    class Ifs{   public static void main(String[] args){   boolean state=false;   int i=1;   if((++i>1)&&(state=true))   i++;   System.out.println(i);  }  } 结果是()  

    • A、5
    • B、编译失败
    • C、运行时异常被抛出
    • D、3
    • E、4

    正确答案:A

  • 第21题:

    单选题
    现有:  class  Ifs  {  public  static void main (String  []  args)  {      boolean state=false;      int i=2;  if( (++i>2)  &&  (state=true))     i++;  if( (++i>4)  l l  (state=false))      i++;  System.out .println (i);     }     } 结果为:()
    A

      6

    B

      5

    C

      4

    D

    编译失败


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

  • 第22题:

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


    正确答案: B
    解析: This code is perfectly legal and the answer is C. 

  • 第23题:

    单选题
    class Ifs{   public static void main(String[] args){   boolean state=false;   int i=1;   if((++i>1)&&(state=true))   i++;   System.out.println(i);  }  } 结果是()
    A

    5

    B

    编译失败

    C

    运行时异常被抛出

    D

    3

    E

    4


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