易搜题 > 资格证大类 > 计算机编程 > 问题详情
问题详情

现有:  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

代码不会完成

未找到的试题在搜索页框底部可快速提交,在会员中心"提交的题"查看可解决状态。 收藏该题
查看答案

相关问题推荐

  • 在方法的声明中,要求该方法必须抛出异常时使用哪个关键字?()     

    A、 throw

    B、 catch

    C、 finally

    D、 throws

  • 现有:   1.  class Alpha { void m1() {} }   2.  class Beta extends Alpha { void m2() { } }   3.  class Gamma extends Beta { }   4.   5.  class GreekTest {   6.    public static void main(String [] args) {   7.      Alpha [] a = {new Alpha(), new Beta(), new Gamma() };   8.      for(Alpha a2 : a) {   9.        a2.m1();    10.       if (a2 instanceof Beta || a2 instanceof Gamma)    11.         //insert code here   12.     }    13.   }   14. }    哪一行代码插入到第11行,将编译但是会在运行时产生异常?() 

    A、 a2.m2();

    B、 ((Beta)a2).m2();

    C、 ((Alpha)a2).m2();

    D、 ((Gamma)a2).m2();

  • 组件的getBounds()方法返回值的类型是哪项?()    

    A、 Dimension

    B、 Rectangle

    C、 Point

    D、 int[]

  • 假设有字符串“123”,能把该字符串变成整数的方法是哪几项?()

    A、Integer.parseInt(”123”)

    B、Float.parseFloat(“123”)

    C、Integer.valueOf(“123”).initValue()

    D、以上都不是

  • 现有   1. class Calc {  2.  public static void main(String [] args) {   3.    try {  4.         int x = Integer.parselnt ("42a") ;   5.     //insert code here  6.         System.out.print ("oops");   7.    }   8.   }   9. }   下面哪两行分别插入到第五行,会导致输 "oops" ? () 

    A

     } catch (IllegalArgumentException e) {

    B

     } catch (IllegalStateException c) {

    C

     } catch (NumbelFormatException n) {

    D

     } catch (ClassCastException c) {

联系客服 会员中心
TOP