参考答案和解析
参考答案:A
更多“switch(i){default:System.out.printIn(Hello”);}Whatistheacceptabletypeforthevariablei?() ”相关问题
  • 第1题:

    switch(i){default:310-025LeadingthewayinITtestingandcertificationtools,www.testking.com-27-System.out.printIn(Hello”);}Whatarethetwoacceptabletypesforthevariablei?()

    A.Char

    B.Byte

    C.Float

    D.Double

    E.Object


    参考答案:A, B

  • 第2题:

    以下程序的输出结果是( )。main(){ int i; for(i=0;i<3;i++) switch(i) { case 0:printf(&quo

    以下程序的输出结果是( )。

    main()

    { int i;

    for(i=0;i<3;i++)

    switch(i)

    { case 0:printf("%d",i);

    case 2:printf("%d",i);

    default:printf("%d",i); }

    }

    A.000102

    B.000020

    C.000122

    D.000111


    正确答案:C
    当i=0时,执行switch语句,对应的执行case0,输出0,因为没有break,接着执行case2的语句,又输出一个0,接着执行default语句,再输出一个0,返回i++;i=1时,没有case语句,执行default语句,输出一个1,接着又返回i++;当i=2时执行case2和default语句分别输出一个2,此时又返回i++,i变为3,for循环不成立,终止,最后输出000122。

  • 第3题:

    运行下列程序时,从键盘输入字母H,则输出结果是()。 #include <stdio.h> int main() { char ch; ch=getchar(); switch(ch) { case 'H':printf("Hello!n"); case 'G':printf("Good morning!n"); default:printf("Good Bye!n"); } }

    A.Hello!

    B.Hello! Good morning!

    C.Hello! Good morning! Good Bye!

    D.Hello! Good Bye!


    C参考答案

  • 第4题:

    给出下列代码段: public class ex38 { public static void main (String args [ ] ) { int m; switch(m) { case 0: System.out.println ( "case 0" ); case 1:System.out.println("case 1");break; case 2: default: System.out.print in ("default") } } 下列m的______值将引起"default"的输出。

    A.0

    B.1

    C.2

    D.以上答案都不正确


    正确答案:C

  • 第5题:

    【单选题】在执行下述程序时,若从键盘输入字母H,则输出结果是_______。 #inlude <stdio.h> main() { char ch; ch=getchar(); switch(ch) { case 'H':printf("Hello! n"); case 'G':printf("Good morning! n"); default:printf("Bye_Bye! n"); } }

    A.Hello!

    B.Hello! Good morning!

    C.Hello! Good morning! Bye_Bye!

    D.Hello! Bye_Bye!


    B 本题中a的值为6,b的值为8,最后s的值为8,s*=s等价于s=s*s。