• 2021-04-14
    请阅读下面的程序
    public class Test {
    public static void main(String[] args) {
    int x;
    int y;
    for (x = 1, y = 1; x <= 100; x++) {
    if (y >= 20) {
    break;
    }
    if (y % 3 == 1) {
    y += 3;
    continue;
    }
    y -= 5;
    }
    System.out.println(“x=” + x + “,y=” + y);
    }
    }
    下列选项中,哪一个是程序的运行结果( )
  • x=8

    内容

    • 0

      写出下面程序运行结果。 public class Demo { public static void main(String args[]) { int x = 9, y = 11, z = 8; int t, w; t = x > y ? x : y + x; w = t > z ? t : z; System.out.println(w); } }

    • 1

      分析以下C#代码,其运行结果是______ using System;class Test{ public static void Main() { int x = 5; int y = x++; y=++x; Console.Write (y); }}

    • 2

      下面程序的输出为( )。 public class Test { public static void main (String args&#91;&#93;) { int x,y; x=1; y=2; System.out.println("The output is"+x+y); } } A: The output is xy B: The output is 3 C: The output is 12 D: The output is x=1 y=2

    • 3

      阅读下面的程序,下面说法中正确的是() public class Test{ public static int x = 10; public static int y = 20; public static void main(String&#91;&#93; args){ public int x = 100; public boolean b = true; System.out.println("x = "+x); System.out.println("b = "+b); System.out.println("y = "+y); } } A: 变量y是局部变量,b是成员变量。 B: 不能输出y的值,这个程序运行后输出的结果是 x=10 b=true C: 这个程序运行后输出的结果是 x=10 b=true y=20 D: 这个程序运行后输出的结果是 x=100 b=true y=20

    • 4

      (7-1)请阅读程序,并写出程序运行结果。 class X{ int getX() { return 5; } } class Y extends X{ int getX() { return 6; } } class T extends X{ int getX() { return 7; } } public class Demo10 { public static void main(String[] args) { X x=new X(); Y y=new Y(); X t=new T(); int sum=x.getX()+y.getX()+t.getX(); System.out.println(sum); } }