The output is x = 6 y = 0
The output is x = 7 y = 0
The output is x = 6 y = -1
The output is x = 7 y = -1
Compilation will fail.
第1题:
下面程序段的输出结果为( )。 package test; public class ClassA { int x=20: static int y=6; public static void main(String args[]) { ClassB b=new ClassB; go(10); System.out.println("x="+b.x); } } class ClassB { int X; void go(int y) { ClassA a=new ClassA; x=a.Y ; } }
A.x=10
B.x=20
C.x=6
D.编译不通过
第2题:
执行如下语句之后,输出的结果是______。 public class ex24 { public static void main(String[] args) { int x=5,y=3; x+=X-- *--y; System.out.println{x); } }
A.0
B.1
C.true
D.false
第3题:
A. x=0,y=2,z=1
B. x=1,y=2,z=1
C. x=0,y=1,z=1
D. x=0,y=2,z=2
第4题:
1. public class X implements Runnable( 2. private int x; 3. private int y; 4. 5. public static void main(String[]args) 6. X that = new X(); 7. (new Thread(that)).start(); 8. (new Thread(that)).start(); 9. ) 10. 11. public void run() ( 12. for (;;) ( 13. x++; 14. y++; 15. System.out.printIn(“x=” + x + “, y = ” + y); 16. ) 17. ) What is the result?()
第5题:
Less Test{ public static void main(String[] args){ for(int x=0;x<7;++x){ int y=2; x=++y; } System.out.println(“y=”+y); } } 结果为:()
第6题:
public class X implements Runnable ( private int x; private int y; public static void main(String args) ( X that = new X(); (new Thread(that)) . start( ); (new Thread(that)) . start( ); ) public synchronized void run( ) ( for (;;) ( x++; y++; System.out.printIn(“x = “ + x + “, y = “ + y); ) ) ) What is the result?()
第7题:
public class IfTest ( public static void main(string[]args) { int x = 3; int y = 1; if (x = y) system.out.printIn(“Not equal”); else system.out.printIn(“Equal”); } ) What is the result?()
第8题:
int x = 1, y =6; while (y--) { x++; } System.out.println(“x =” + x + “y =” +y); What is the result?()
第9题:
The output is “Equal”
The output in “Not Equal”
An error at line 5 causes compilation to fall.
The program executes but does not print a message.
第10题:
x = 6 y = 0
x = 7 y = 0
x = 6 y = -1
x = 7 y = -1
Compilation fails.
第11题:
An error at line 11 causes compilation to fail.
Errors at lines 7 and 8 cause compilation to fail.
The program prints pairs of values for x and y that might not always be the same on the same line (for example, “x=2, y=1”)
The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”)
The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=2s, y=2”)
第12题:
6
7
8
10
第13题:
下面程序段的输出结果为 package test; public class A { int x=20; static int y=6; public static void main(String args[]) { Class B b=new Class B(); b.go(10); System.out.println(”x=”+b.x); } } class Class B { int x; void go(int y) { ClassA a=new ClassA(); x=a.y; } }
A.x=10
B.x=20
C.x=6
D.编译不通过
第14题:
执行如下语句之后,输出的结果是______。 public class ex36 { public static void main(String[] args) { int x=-6, y=6; x=x+y--; System.out.println (x); } }
A.-12
B.12
C.-1
D.0
第15题:
第16题:
class DemoApp{ public static void main(String[] args){ int x = 5; int y = ++x + x++; S ystem.out.println(“y=”+y+”,x=”+x); } } 以上程序运行后的输出结果是哪项?()
第17题:
public class WhileFoo { public static void main (String []args) { int x= 1, y = 6; while (y--) {x--;} system.out.printIn(“x=” + x “y =” + y); } } What is the result?()
第18题:
class Foo { public static void main(String [] args) { int x = 0; int y = 4; for(int z=0; z 〈 3; z++, x++) { if(x 〉 1 & ++y 〈 10) y++; } System.out.println(y); } } 结果是什么?()
第19题:
public class IfTest ( public static void main(stringargs) { int x = 3; int y = 1; if (x = y) system.out.printIn(“Not equal”); else system.out.printIn(“Equal”); } ) What is the result?()
第20题:
The output is “Equal”
The output in “Not Equal”
An error at line 5 causes compilation to fall.
The program executes but does not print a message.
第21题:
y=5
y=6
y=7
y=8
编译失败
运行时异常被抛出
第22题:
The output is x = 6 y = 0
The output is x = 7 y = 0
The output is x = 6 y = -1
The output is x = 7 y = -1
Compilation will fail.
第23题:
y=10,x=5
y=11,x=6
y=12,x=7
y=11,x=7
第24题:
The output is X = 6 y = 0
The output is x = 7 y = 0
The output is x = 6 y = -1
The output is x = 7 y = -1
Compilation will fail.