首页 > 试题广场 >

改错di

[问答题]
改错

class Student



{ int a=10


S tatic int geta()

{ return a;}

}

class Student
{ static int a=1;
  static int geta(){ return a;}
}
这里的考点是static修饰的作用,static方法不依附于任何对象所以当其调用Student对象中的变量a时是定位不到的

发表于 2018-12-19 17:41:55 回复(0)