3
5
编译失败
运行时异常被抛出
第1题:
下面程序段的输出结果为 package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.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题:
下面程序段的输出结果为 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.编译不通过
第3题:
A.3
B.5
C.编译失败
D.运行时异常被抛出
第4题:
import java.util.*; class Banana3 { public static void main(String [] args) { int x = 2; Banana3 b = new Banana3(); b.go(x); } static { x += x; } void go(int x) { ++x; System.out.println(x); } } 结果为:()
第5题:
有以下源程序: package test; public class ClassA { int x=20; static int y=6; public static void main(String args[]) { ClassB b=new ClassB(); b.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.编译不通过
第6题:
下面程序段的输出结果为( )。 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.编译不通过
第7题:
下面的例子中
using System;
class A
{
public static int X;
static A(){
X=B.Y+1;
}
}
class B
{
public static int Y=A.X+1;
static B(){}
static void Main(){
Console.WriteLine("X={0},Y={1}",A.X,B.Y);
}
}
产生的输出结果是什么?
第8题:
A.3
B.5
C.编译失败
D.运行时异常被抛出
第9题:
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); } } 结果为:()
第10题:
现有: class TestMain { static int x = 2; static { x = 4; } static public void main(String[] args) { int y = x + 1; System.out.println(y); } } 和命令行: java TestMain 结果为:()