万能百科  > 计算机   > 

[填空题] 下列是一个类的定义,将程序段补充完整。   class A     String s;   ______int a=66;   A(String s

2021-07-20   

[填空题] 下列是一个类的定义,将程序段补充完整。

   class A

    String s;

   ______int a=66;

   A(String sl) s=sl;

   static int geta( ) return a;

正确答案:

static

参考解析:

考查static关键字的用法。[解题要点] static方法只能处理static成员;非static方法不能处理static成员。所以题目中的geta()方法声明是static的,所以其中的变量必须也声明为static属性。[考点链接] static方法只能用类名来引用,所以static方法不能用this来引用。因为 this表示当前对象,而并非当前类。

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。

标签