首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z()
有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z()
admin
2010-07-28
34
问题
有如下的代码段,当编译和运行时,下列各选项中说法正确的是( )。 public class Z { public static void main(String args[]) { new Z(); } Z() { Z aliasl=this; Z alias2=this; synchronized(aliasl) { try{ alias2.walt(); System.out.println("DONE WAITING"); } catch(InterruptedException e) { System.out.println("INTERR UPTED"); } catch (Exception e) { System.out.println("OTHER EXCEPTION"); } finally{ System.out.println("FINALLY"); } } System.out.println("ALL DONE"); } }
选项
A、应用程序编译正常,但是不打印任何数据
B、应用程序编译正常,并打印数据“DONE WAITING”
C、应用程序编译正常,并打印数据“FINALLY”
D、应用程序编译正常,并打印数据“ALL DONE”
答案
1
解析
在Java中,每一个对象都有锁。任何时候,该锁都至多由一个线程控制。由于 aliasl与alias2指向同一对象Z,在执行第11行前,线程拥有对象z的锁。在执行完第11行后,该线程释放了对象Z的锁,进入等待池。但此后没有线程调用对象Z的notify()和 notifyAll()方法,所以该进程一直处于等待状态,没有输出。
转载请注明原文地址:https://kaotiyun.com/show/AQ9p777K
本试题收录于:
二级Java题库NCRE全国计算机二级分类
0
二级Java
NCRE全国计算机二级
相关试题推荐
对建立良好的程序设计风格,下面描述正确的是
软件开发环境是全面支持软件开发全过程的____________集合。
在关系模型中,把数据看成一个二维表,每一个二维表称为一个
软件工程包括3个要素,分别为方法、工具和
对于长度为n的线性表,在最坏情况下,下列各排序法所对应的比较次数中正确的是
设有表示学生选课的三张表,学生表S(学号,姓名,性别,年龄,身份证号),课程表C(课号,课名),选课表SC(学号,课号,成绩),则表SC的关键字(键或码)为()。
在标准ASCII码表中,已知英文字母E的ASCII码是01000101,英文字母B的ASCII码是
根据域名代码规定,表示政府部门网站的域名代码是
结构化程序设计中,下面对goto语句使用描述正确的是
随机试题
苏美尔一巴比伦文学的最高峰是
建立共同愿景属于()的管理观念。
吴荪甫是茅盾长篇小说《》的主人公。
某女,妊娠4个月,突然发热,下腹持续性腹痛,妇检:子宫如孕4个半月大小,前壁可触及乒乓球大小不活动肿块,质硬,有压痛,两侧附件阳性。
男,4岁,被牵拉上台阶时突然哭闹,拒绝使用右上肢。进一步处理是
均匀扩散材料的最大发光强度与材料表面法线所成的夹角为:[2006年第17题]
施工方进度计划的任务不包括()。
(2017年)2015年6月30日,长江公司销售一批商品给黄河公司,应收账款总额为8500万元,款项尚未收到。2015年12月31日,长江公司对该项债权计提坏账准备80万元。2016年1月1日,长江公司应确认的债务重组损失为()万元。
道德修养是一种自我行为,只求诸己,不求诸人。“君子之自行也,敬人而不必见敬,爱人而不必见爱。敬爱人者,己也;见敬爱者,人也。君子必在己者,不必在人者也”(《吕氏春秋•必己》)。以敬爱他人为例,对他人的尊敬或爱护,只问这种敬与爱是否出自真心,是否做得彻底,而
AccordingtoParagraph2,thewriterthinksthat______.WhichofthefollowingstatementsisNOThueaccordingtothepassage
最新回复
(
0
)