• 2021-04-14
    写出下面程序运行结果。public class Demo public static void main(String args[]) int x = 5, y = 10, r = 5 switch (x y) case 15: r = x case 20: r -= y case 25: r = x / y default: r = r System.out.println(r)
  • 0

    内容

    • 0

      (6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }

    • 1

      阅读程序,分析输出结果是()。​#include [stdio.h]​void main()​{ ​int x=10,y=5; ​switch(x) ​{ case 1:x++; ​default: x+=y;​case 2:y--;​case 3:x--;​}​printf("x=%d,y=%d",x,y);​}​‎​ A: x=14,y=4 B: x=15,y=5 C: x=10,y=5 D: x=15,y=4

    • 2

      阅读程序,分析输出结果是()。#include [stdio.h]void main(){ int x=10,y=5; switch(x) { case 1:x++; default: x+=y;case 2:y--;case 3:x--;}printf("x=%d,y=%d",x,y);} A: x=15,y=5 B: x=10,y=5 C: x=14,y=4 D: x=15,y=4

    • 3

      从($y)("x)R(x,y)不能推出的是: A: ("x)($y)R(x,y) B: ("y)($x)R(x,y) C: ($x)($y)R(x,y) D: ($y)($x)R(x,y)

    • 4

      有以下程序段,运行后的输出结果是( ) #include main() {int x=10,y=5; switch(x) { case 1: x++; default:x+=y; case 2:y--; case 3:x--; } printf(“x=%d,y=%d”,x,y); } A: x=15,y=5 B: x=10,y=5 C: x=14,y=4 D: x=15,y=4