两个线程并发执行以下代码,假设a是全局变量,那么以下输出()哪个是可能的。
A、32
B、23
C、33
D、22
相关问题推荐
-
现有 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) {
-
组件的getBounds()方法返回值的类型是哪项?()
A、 Dimension
B、 Rectangle
C、 Point
D、 int[]
-
现有: 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代码不会完成
-
已知表达式intm[]={0,1,2,3,4,5,6};下面哪个表达式的值与数组下标量最大值相等()。
A、m. length()
B、m. length-1
C、m. length()+1
D、m. length+1
-
假设有字符串“123”,能把该字符串变成整数的方法是哪几项?()
A、Integer.parseInt(”123”)
B、Float.parseFloat(“123”)
C、Integer.valueOf(“123”).initValue()
D、以上都不是