首页 > 试题广场 >

关于以下程序代码的说明正确的是(  &n

[不定项选择题]
关于以下程序代码的说明正确的是(     )。
class  HasStatic{
private  static  int  x=100;
public  static  void  main(String  args[  ]){
HasStatic  hs1=new  HasStatic(  );
hs1.x++;
HasStatic  hs2=new  HasStatic(  );
hs2.x++;
hs1=new  HasStatic( );
hs1.x++;
HasStatic.x--;
System.out.println(“x=”+x);
}
}
  • 5行不能通过编译,因为引用了私有静态变量
  • 10行不能通过编译,因为x是私有静态变量
  • 程序通过编译,输出结果为:x=103
  • 程序通过编译,输出结果为:x=102

这道题你会答吗?花几分钟告诉大家答案吧!