A-A+

下面是一个类的定义 试将程序补充完整。 class Test { String s; 【 】

2022-08-12 20:05:26 问答库 阅读 197 次

问题详情

下面是一个类的定义,试将程序补充完整。 class Test { String s; 【 】int a =66; Test(String s1) { s=s1; } static int geta() { return a; } }


请帮忙给出正确答案和分析,谢谢!

参考答案

正确答案:static
本题考查Java中的修饰符。static方法只能处理static成员,非static方法不能处理static成员。题目中的geta()方法声明是static的,所以其中的变量也必须声明为static属性。

考点:定义,程序