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);
}
}
下列选项中,哪一个是程序的运行结果( )
举一反三
- using System; class Test { public static void Main() { int x = 5; int y = x++; Console.WriteLine(y); y=++x; Console.WriteLine(y); } }
- 写出以下程序的运行结果。using System;class Test{public static void Main(){int x = 5;int y = x++;Console.WriteLine(y);//第1空y=++x;Console.WriteLine(y);//第2空}}
- 1. 写出以下程序的运行结果。 class Test { public static void Main() { int x = 5; int y = x++; Console.WriteLine(y); y=++x; Console.WriteLine(y); Console.WriteLine(x); } } 运行结果:
- (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(); } }
- 写出下面程序运行结果。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
写出下面程序运行结果。 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[]) { 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[] 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); } }