[单选题]

下面程序段的输出结果为 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.编译不通过

参考答案与解析:

相关试题

下面程序段的输出结果为package test;public class A {

[单选题]下面程序段的输出结果为 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; }

  • 查看答案
  • 3下面程序段的输出结果为()。package test;public class

    [单选题]3下面程序段的输出结果为( )。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

  • 查看答案
  • 下面程序段的输出结果为public class Test{public stat

    [单选题]下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.println(”a=”+a+”b=+b) ; c=(b==false); System.out.printhln(”b=”+b+”c=”+c) ; } }A.a=true b=false b=true c=falseB.a=true b=false

  • 查看答案
  • 下面程序段的输出结果为public class Test{public stat

    [单选题]下面程序段的输出结果为 public class Test { public static void main(String args[]) { boolean a,b,c; a=(3<5); b=(a==true); System.out.println("a="+a+"b="+B); c=(b==false); System.out.println("b="+b+"c="+C); } }A.a=true b=false b=true c=falseB.a=true b=fal

  • 查看答案
  • 下面程序段的输出结果是( )。public class Test {public

    [单选题]下面程序段的输出结果是( )。 public class Test { public static void main ( String[] args) { int result=0; for ( int i=1;i<=5;i++) { if ( i%2==0 ) continue; result + =i; } System. out. println ("result is " + result ); } }A.result is 7B.result is 8C.result is 9D

  • 查看答案
  • 下面程序段的输出结果是()。 public class Test {public

    [单选题]下面程序段的输出结果是( )。 public class Test {public static void main(String args[]){ int[] a=new int[11]; int[] p=new int[4]; int k=5; for(int i= 1 ; i<= 10;i++) a[i]=i; for(int i=1 ; i<=3;i++) p[i]=a[i*i]; for(int i= 1 ;i<=3;i++) k=k+p[i]*2; System.out.printl

  • 查看答案
  • 下面程序段的输出结果是()。public class Test { public

    [单选题]下面程序段的输出结果是( )。 public class Test { public static void main(String args[ ]){ int x,y; x=(int)Math.sqrt(5)/2+(int)Math.random()*5/2; y=(int)Math.sqrt(3)/2+(int)Math.random()*3/2; if (x>y) System.out.println("x>y"); else if (x==y) System.out.println(

  • 查看答案
  • 下面程序段的输出结果是( )。public class Test {public

    [单选题]下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int n=10; do { System.out.println("n is"+n); }while(--n>10); } }A.n is 8B.没有输出C.n is 10D.n is 9

  • 查看答案
  • 下面程序段的输出结果是( )。public class Test {public

    [单选题]下面程序段的输出结果是( )。 public class Test { public static void main (String[) args) { int a,b; for(a=1,b=1;a<=100;a++) { if (a>=10 ) break; if (b%2==1) { b+=2; continue; } } System. out. pdntln(A); } }A.7B.8C.9D.10

  • 查看答案
  • 下面程序段的输出结果是( )。public class Test {public

    [单选题]下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int sum=0; for ( int i=0;i<=100; i++) sum+=i; System. out. println ("sum="+sum); } }A.sum =5050B.sum=4950C.sum=0D.sum=100

  • 查看答案
  • 下面程序段的输出结果为package test;public class Cla