问题 单项选择题

阅读下面程序 import java.io.*; public class TypeTransition{public static void main(String args[]){ char a=’h’; int i=100; int j=97; int aa=a+i; System.out.println("aa="+aA) ; char bb=(char)j; System.out.println("bb="+bB) ;} } 如果输出结果的第二行为bb=a,那么第一行的输出是

A.aa=I

B.aa=204

C.aa=v

D.aa=156

答案

参考答案:B

解析: 本题考查的是Java的基本数据类型及其运算。程序开始生成了一个字符型变量a和3个整型变量i、j、aa。而整型变量aa的初始值是a+i,其中a是一个字符型变量。如何进行加法运算呢Java语言规定,char型数据可以自动转换成int类型,转换的结果就是该字符的ASCII码值。因此,整型变量aa的初始值为字符“h”的 ASCH码值加上100。如果记住h的ASCII码值是104,则直接就确定aa的初始值是 204,选项B为正确答案。 如果记不得h的ASCII码,题目中则给出提示。题目中说“输出结果的第二行为bb=a”,也就是字符比的值为字符a,bb的生成语句是char bb;(char)j,是把整型变量j的值强制转换为字符型。同样,把ASCH码值为.j(97)所对应的字符赋值给比。显然,字符a的ASCII码值为97,字符b的ASCII码值为98,依次类推,字符h的ASCII码为104。 因此,本题的正确答案是B。

单项选择题 B型题
完形填空
     One day a famous actor had just got into the train with all his luggage when a young man came and   1  
down in the seat opposite him. The young man took out a   2   and began to read it,  3   the actor tried to
get some   4   in his corner of the carriage.
     When he opened his eyes,  he   5   that the young man was looking at him with his   6   open, his book
forgotten. The actor shut his eyes and tried to sleep again,  7   every time he opened them, the young man
was looking at him with the same excited look .At last, he gave up the attempt(企图) to sleep, took out a
newspaper, put it   8   in front of him and began to read. The young man tried several times to get into
conversation with the actor, but   9  .
     After a long period of silence the young man said again, "I'm George P. Anderson of Willington,
Vermont."This time the actor put his   10   down and said, "So am I."That was the end of the conversation.
( )1. A. lay      
( )2. A. newspaper
( )3. A. when    
( )4. A. drink    
( )5. A. found    
( )6. A. book    
( )7. A. but      
( )8. A. away    
( )9. A. failed  
( )10. A. paper    
B. sat      
B. magazine  
B. because  
B. help      
B. thought  
B. mouth    
B. therefore
B. up        
B. succeeded
B. luggage  
C. looked  
C. book    
C. as      
C. food    
C. felt    
C. arms    
C. so      
C. down    
C. missed  
C. feet    
D. got    
D. letter  
D. while  
D. sleep  
D. expected
D. shirt  
D. however
D. out    
D. refused
D. hands