下列程序从标准输入设备--键盘读入-个字符,然后输出到屏幕。要想完成此功能,画线处应该填入的语句为( )。A.ch=System.in.read( );B.ch=(char)System.in.read( );C.ch=(char)System.in.readln( );D.ch=(int)System.in.read( );

题目

下列程序从标准输入设备--键盘读入-个字符,然后输出到屏幕。要想完成此功能,画线处应该填入的语句为( )。

A.ch=System.in.read( );

B.ch=(char)System.in.read( );

C.ch=(char)System.in.readln( );

D.ch=(int)System.in.read( );


相似考题
更多“ 下列程序从标准输入设备--键盘读入-个字符,然后输出到屏幕。要想完成此功能,画线处应该填入的语句为( )。A.ch=System.in.read( );B.ch=(char)System.in.read( );C”相关问题
  • 第1题:

    下列程序从标准输入设备——键盘读入一个字符,然后输出到屏幕。要想完成此功能,画线处应该填人的语句为( )。 importjava.iO.*; public class Test { public static void main(String argsE]) { charch: try { ___; System.out.println(eh); } catch(IOException e) { e.printStackTrace: } } }

    A. ch=System.in.read:

    B.ch=(char)System.in.read:

    C.ch=(char)System.in.readln:

    D.ch=(int)System.in.read;


    正确答案:B
    B【解析】此题程序通过调用系统的标准输入流System.in的read方法,从键盘读入一个字符,由于read方法的返回值是int类型,而变量ch是字符类型,不能直接转换,因此需要进行强制类型转换,应该填入的正确语句是ch=(char)System.In.read。

  • 第2题:

    下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是( )。 Importjava.io.*; publicclassExam{ publicstaticvoidmain(Stringargs[]){ intch=0; System.out.println("输入一个字符:"); try{ ch=System.in.read(); charch_A='A',ch_Z='Z'; intdelta_c=(inoch_A+(int)ch_Z-ch; System.out.println("编码后的字符为:"+(char)delta_c); } catch(IOExceptione){ e.printStackTrace(); } } }

    A.C

    B.Y

    C.X

    D.字母C的ASCII码的整型值


    正确答案:C
    解析: 本题考查考生阅读Java程序的能力。当使用h=System.in.read()语句从键盘读入大写字母C赋给ch,此时 ch值为67,也就是字母C的ASCII值。语句(int)ch A+(int)ch.Z-ch结果为88,ASCII码中的88相当于字母X,所以输出为X,选项C正确。

  • 第3题:

    20、下列描述中,正确的是()。

    A.cin对应标准输入流,用于从键盘读取数据

    B.cout对应标准输出流,用于从键盘读取数据

    C.cout对应标准输入流,用于将数据输出到屏幕上

    D.cin对应标准输出流,用于将数据输出到屏幕上


    A

  • 第4题:

    下列程序中,若从键盘中输入的是大写字母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; } } }

    A.C

    B.Y

    C.X

    D.字母C的ASCIl码的整型值


    正确答案: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正确。

  • 第5题:

    下列程序中,若从键盘中输入的是大写字母C,则程序输出的结果是 import java.io.*; public class Exam{ public static void main(String args[]) int ch=0; System.out.println(”输入一个字符:”); try{ ch=System.in.read(); char ch_A='A',ch_Z='Z',; int delta_c=(int)ch_A+(int)ch_Z-ch; System.out.println(”编码后的字符为:”+(char)delta_c); } catch(IOException e){ e.printStackTrace(); } } }

    A.C

    B.Y

    C.X

    D.字母C的ASCII码的整型值


    正确答案:C
    解析:本题考查考生阅读Java程序的能力。当使用ch=System.in.read()语句从键盘读入大写字母C赋给ch,此时ch值为67,也就是字母C的ASCII值。语句(int)ch A +(int)ch_Z-ch结果为88,ASCII码中的88相当于字母X,所以输出为X,选项C正确。