问题 单项选择题

阅读下列代码 public class Test 2005{ public static void main(String args[]){ System.out.println(~(0xa5)&0xaA) ; } } 其运行结果是【 】

A.0xa5

B.10

C.0x50

D.0xaa

答案

参考答案:B

解析:这段程序代码非常简单,就是在屏幕上输出表达式~(Oxa5)&Oxaa的结果。"~"和"&"是位逻辑运算符:按位取反运算符"~"的运算规则是对数据的每个二进制位取反,即把1变为0,把0变为1;按位与运算符"&"的运算规则是,如果两个操作数中,相应位都为1,则该位的结果为1,否则为0。 解答这道题,首先要把十六进制数Oxa5和Oxaa转换为二进制数的形式,转换的方法是把一位十六进制用四位二进制表示。因此,Oxa5的二进制形式为10100101,Oxaa的二进制形式为10101010。在位运算符中,"—"的优先级高于"&"。所以首先计算~10100101,其结果为01011010。然后再计算01011010&10101010,其结果为 00001010。最后将二进制数00001010转换为十进制数,即为10。因此,本题的正确答案是10。

阅读理解

阅读理解。

     This story about an old man and a clever monkey is a very old one. Aesop, a Greek writer, first told

the story many years ago. This monkey belonged to an old man. The old man was very fond of the garden,

so when birds came to the garden, he chased them away. He also helped the old man in many other ways.

The old man often fell asleep during the day in his chair. Then the monkey sat at the old man's side and

chased the flies away from the old men's face.

     One hot afternoon in the summer, the old man was asleep in his chair. A fly came and sat on the end

of the old man's nose. The monkey chased it away. Soon the fly came back and sat on the old man's

nose again. The monkey chased it away. This continued for five or six times. The monkey at last became

very angry. He jumped up, ran to the garden, and picked up a large stone. The next time when the fly sat

on the old man's nose, the monkey hit it hard with the stone. He killed the fly, but unfortunately he broke

the old man's nose.

1. This story was first told by a Greek _____. [ ]

A. famous poet

B. great philosopher

C. fable writer

D. well-known physicist

2. When birds came to the garden, the monkey chased them away. The verb "chase" means _____. [ ]

A. drive out

B. get hold of

C. catch up with

D. keep up with

3. The monkey picked up a large stone, because he wanted _____. [ ]

A. to fight to death

B. to put the fly to death

C. to hit the fly on the head

D. to strike the old man on the nose

4. The monkey at last became angry, because _____. [ ]

A. the old man didn't give him anything to eat

B. the old man made the monkey do nothing

C. the old man often fell asleep during the day in his armchair

D. He couldn't drive the fly away

5. Which of the following statements is true according to this passage?[ ]

A. From this story we can learn; sometimes things done out of harmful will may be good.

B. From this story we can learn; sometimes things done out of good will may be good.

C. From this story we can learn; sometimes things done out of harmful will may be harmful.

D. From this story we can learn; sometimes things done out of good will may be harmful.

单项选择题