搜题
网友您好,请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
提问人:网友farshine 发布时间:2022-01-07
[主观题]

class Computation extends Thread {

private int num;

private boolean isComplete;

private int result;

public Computation(int num) { this.num = num; }

public synchronized void run() {

result = num * 2;

isComplete = true;

notify();

}

public synchronized int getResult() {

while (!isComplete) {

try {

wait();

} catch (InterruptedException e) { }

}

return result;

}

public static void main(String[] args) {

Computation[] computations = new Computation [4];

for (int i = 0; i< computations.length; i++) {  computations[i] = new computation(i);  computations[i] .start();  }  for (computation c : computations)  system.out.print(c.getresult() +“ “);  }  }  what is the result?()

A.  The code will deadlock.

B.  The code may run with no output.

C.  An exception is thrown at runtime.

D.  The code may run with output “0 6”.

E.  The code may run with output “2 0 6 4‟.

F .  The code may ruin with output “0 2 4 6”.

简答题官方参考答案 (由简答题聘请的专业题库老师提供的解答)
查看官方参考答案
更多“class Computation extends Thread {”相关的问题
第1题

编译JavaApplication源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为()。

A.java

B.class

C.html

D.ex

点击查看答案
第2题
下面代码中,第7行横线处应该填入class MyExcept {}; int main() { try { MyExcept ex; throw ex; } catch (________) { } return 0; }

A.MyExcept &e

B.MyExcept *e

C.MyExcept ~e

D.std::exception e

E.std::exception &e

点击查看答案
第3题
设有以下类的定义:class Ex{ int x;public:void setx(int t=0);};若在类外定义成员函数setx(),以下定义形式中正确的是

A.void setx(int t){…}

B.void Ex::setx(int t){…}

C.Ex::void setx(int t){…}

D.void Ex::setx(){…}

点击查看答案
第4题
public class Ex { public static void main(String args[]) { int x = 5, y = 10; boolean result = x++ > 5 && ++y > 10; System.out.println("x:" + x + ",y:" + y); } } 运行以上程序,输出 y 的值为()。
点击查看答案
第5题
以下代码,哪一行会报错 class Example { String str; public Example(){ str = "example"; } pub

以下代码,哪一行会报错 class Example { String str; public Example(){ str = "example"; } public Example(String s){ str = s; } } class Demo extends Example{ } public class Test{ public void f(){ Example ex = new Example("Good"); Demo d = new Demo("Good"); } }

A、行4

B、行8

C、行13

D、行17

E、行18

点击查看答案
第6题
下列程序执行之后,将会输出()。interface Com{ int Max=800; int on(); } class A implements Co

下列程序执行之后,将会输出()。interface Com{ int Max=800; int on(); } class A implements Com{ public int on(){ return Com.Max; } } public class Ex { public static void main(String args[]) { Com com=new A(); int m=com.on(); System.out.printf("%d",m); } }

点击查看答案
第7题
设EX=1,DX=4,则由切比雪夫不等式由P(-5<x> <7) class="kfformula" data-latex="\geq " width="47" height="33" style="width:47px;height:33px" src="http://static.jiandati.com/25e004c-chaoxing2016-718080.png">().

A.1/3

B.2/3

C.1/9

D.8/9

点击查看答案
第8题
【分录题】(7-1)请阅读程序,并写出程序运行结果。 class X{ int getX() { return 5; } } class Y ex

【分录题】(7-1)请阅读程序,并写出程序运行结果。 class X{ int getX() { return 5; } } class Y extends X{ int getX() { return 6; } } class T extends X{ int getX() { return 7; } } public class Demo10 { public static void main(String[] args) { X x=new X(); Y y=new Y(); X t=new T(); int sum=x.getX()+y.getX()+t.getX(); System.out.println(sum); } }

点击查看答案
第9题
下列程序中哪些【代码】是错误的?若有错误,请给出正确语句。 public class Ex { public static void main(String args[]) { int x=8; byte b=-127; //【代码1】 b=x; //【代码2】 x=12L; //【代码3】 long y=8.0; //【代码4】 float z=5.543; //【代码5】 } }
点击查看答案
第10题
程序运行的结果是:_______________。 public class Example{ String str=new String("good");

程序运行的结果是:_______________。

public class Example{

String str=new String("good");

char[]ch={'a','b','c'};

public static void main(String args[]){

Example ex=new Example();

ex.change(ex.str,ex.ch);

System.out.print(ex.str+" and ");

Sytem.out.print(ex.ch);

}

public void change(String str,char ch[]){

str="test ok";

ch[0]='g';

}

}

点击查看答案
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)

订单号:

遇到问题请联系在线客服

请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示:请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

- 微信扫码关注简答题 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注简答题 -
请用微信扫码测试
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

简答题
下载APP
关注公众号
TOP