单选题
Java
题号 #2246932
下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是( )。
Importjava.io.*;
public class Exam{
public static void main(String args[]){
int ch=0;
System.out.println("输入一个字符:");
try{
ch=System.in.read();
charch_A='A',ch_Z='Z';
int delta c=(int)ch A+(int)ch Z-ch;
syStem. out.println("编码后的字符为:"+(char)delta_c);
}
catch(IOException e){
printStackTrace();
}
}
}
参考答案
C
答案解析
C。【解析】本题考查考生阅读Java程序的能力。当使用h=System.in.read()语句从键盘读入大写字母C赋给ch,此时ch值为67,也就是字母C的ASCIl值。语句(int)ch_A+(int)ch_Z-ch结果为88,ASCIl码中的88相当于字母X,所以输出为X,选项C正确。
你可能感兴趣的试题
A.true
B.false
C.test
D.编译错误