问题 单项选择题

已知有下面的类说明:
public class Test4

private float f=1.0f;
int m=12;
static int n=1;
public static void main(String args[])

Test4 e=new Test4();


在main()方法中,下面哪个的使用是正确的 ( )

A.f

B.this.n

C.Test4.m

D.Test4.f

答案

参考答案:A

解析: 该题考查的是怎样引用对象的变量。访问对象成员变量的格式为:对象名.成员变量名。在本题中使用Test4 e=new Test4();语句生成了对象并由变量e引用后,可以通过上述格式访问对象的成员f,即e.f。所以本题选A。

填空题
单项选择题