Topic: 帮我看看几到SCJP的题 |
Print this page |
1.帮我看看几到SCJP的题 | Copy to clipboard |
Posted by: AchillesA Posted on: 2005-05-27 09:04 +----------------------------------------------------------+ class s implements Runnable{ int x=0,y=0; synchronized void addX(){x++; } synchronized void addY(){y++; } void addXY(){x++;y++;} boolean check() { return (x>y)? true:false public void run() { //// System.out.println(check()); } public static void main(String args[]) { s run=new s(); Thread t1=new Thread(run); Thread t2=new Thread(run); t1.start(); t2.start(); } } If this methods are called in which order the check will return true? Select all that apply call addX() and addY() simultaneously for number of times in run() call addY() and addX() simultaneously for number of times in run() all addXY() for number of times in run() 答案:? +--------------------------------------------------------------+ class Outer{ class Inner{} } How will you create an instance of Inner Class out side? Select 2 Inner a= new Inner(); Outer o= new Outer();Inner a= new o.Inner(); Outer o= new Outer();Outer.Inner a= new o.Inner();//?不行 Outer.Inner a= new Outer().new Inner(); ans:cd? +--------------------------------------+ |
2.Re:帮我看看几到SCJP的题 [Re: AchillesA] | Copy to clipboard |
Posted by: kaiserlew Posted on: 2005-05-29 13:22 1。d 2。cd |
3.Re:帮我看看几到SCJP的题 [Re: AchillesA] | Copy to clipboard |
Posted by: AchillesA Posted on: 2005-05-30 12:50 第二题的答案C Outer o= new Outer();Outer.Inner a= new o.Inner(); 好像是不可以吧,我测试了下,结果是不能通过编译。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |