试题与答案

下面程序执行后,输出的值应是______。 public classs Test

题型:单项选择题

题目:

下面程序执行后,输出的值应是______。
public classs Test10

public static void main(String[] args)

float a=5, b=4, c=3;
if ( --a==b )
c=--a/c;
System.out.println(c);

A.1.33

B.1.0

C.0.0

D.1.67

答案:

参考答案:B

解析: 程序做--a,得到a=4.0f,再与b做比较,结果相等,条件表达式为true,执行条件分支,先做-a得到a=3.0f,再和c做除法,得到1.0f,并把结果赋给c,因此c的值为1.0f。

试题推荐
题型:阅读理解

阅读理解

     An 8 -year-0ld girl was dragged about 900 feet by a school bus today in Livingston County.

     According to State Police, the incident occurred about 2:40 p. m.  on State Route 436 in the town of

Ossian after three sisters were dropped off the bus.

     As the last sister was leaving the bus, driver John Coley, 62, of Wayland, Steuben County, told police

that he was not paying attention when he closed the door and trapped her backpack inside. Coley then

continued 900 feet before he realized the girl was being dragged, State Police said.

     The girl was hurt and was transported to Nicholas H. Noyes Memorial Hospital in Dansville,

Livingston County, by Dansville Ambulance.

    Another 8-year-old child on the bus said he hit his head on the seat in front of him when the bus came

to a sudden stop, causing an earache.

     Conservation staff in New Zealand have put down 33 stranded(搁浅)whales after several attempts to

refloat them failed.

     The whales shot Thursday were the last of 99 that stranded themselves Monday on Farewell Spit on

the South Island. Department of Conservation area manager John Mason says staff and hundreds of

volunteers had tried all week to get the whales refloated.

      He says they thought they were successful Wednesday when they got the whales into deep

water-but were saddened Thursday to find that they had swum back ashore. He says the condition of

the whales had significantly become worse.

      As well as the 33 whales that were shot, 36 had died naturally since Monday and 17 were

successfully refloated. Thirteen remain unknown.

1. The last sister was dragged by the bus because_______.

A. she stood too close to the bus when getting off

B. the bus driver stopped the bus suddenly

C. something was wrong with the bus door

D. her backpack was stuck in the closed door

2. It can be inferred from the first news that_________.

A. three sisters were dragged about 900 feet by a school bus

B. the driver stopped the bus immediately he realized his mistake

C. two children were hurt and sent to hospital

D. a boy was hurt when the bus started suddenly

3. How many whales were trapped ashore in total?

A. 33            

B. 36        

C. 99            

D. 13

4. The 33 refloated whales returned ashore on_________

A. Monday        

B. Tuesday        

C. Wednesday        

D. Thursday

查看答案
微信公众账号搜索答案