首页 试题详情
单选题

阅读下列程序 public class VariableUse{ public static void main (String[] args) { int a; if (a==8) { int b=9; System.out.println("a = "+a); System.out.println("b = "+b); } System.out.println("a = "+a); System.out.println("b = "+b); } } 该程序在编译时的结果是:

A变量a未赋值

B第二个System.out.println(“b = ”+b)语句中,变量b作用域有错

C第二个System.out.println(“a = ”+a)语句中,变量a作用域有错

D第一个System.out.println(“b = ”+b)语句中,变量b作用域有错

正确答案:A (备注:此答案有误)

相似试题

  • 单选题

    阅读下列程序public class VariableUse{ public static void main (String[] args) { int a; if (a==8) { int b=9; System.out.println(a = +a); System.out.println(b = +b); } System.out.println(a = +a); System.out.println(b = +b); }}该程序在编译时的结果是:

    答案解析

  • 单选题

    阅读下列程序 public class Test implements Runnable{   private int x=0;   private int y=o;   boolean flag=true;   public static void main(string[ ] args) {     Test r =new Test( );     Thead t1=new Thead(r);     Thead t2=new Thead(r);     t1.start( );     t2.start( );   }   public void run(){     while(flag) {       x++;       y++;       System.out.println(( +x_ ,+y+));       if (x>=10)         flag=false;     }   } } 下列程序运行结果描述的选项中,正确的是:

    答案解析

  • 单选题

    阅读下列利用递归来求n!的程序class FactorialTest{ static long Factorial (int n) { //定义Factorial ()方法 if (n==1) return 1; else return n* Factorial(_____); } public static void main (String a[]) { // main ()方法 int n=8; System.out.println{n+! = +Factorial (n)}; }}为保证程序正确运行,在下划线处应该填入的参数是:

    答案解析

  • 单选题

    下列程序的运行结果是:public class test{  private String[] data={10,10.5};  public void fun(){    double s=0;    for(int i=0;i

    答案解析

  • 单选题

    阅读以下代码,输出结果为()class A{public: virtual void a()=0; virtual ~A(){}};class AA:public A{public: void a() { cout

    答案解析

热门题库