[问答题] 请在每条横线处填写一个语句,使程序的功能完整,且输出结果为91 1。
注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
public class Outer
public static void main (String args[]
Outer i = new Outer();
i,taskInner();
public class Inner
private int size;
public void doSomething(int size)
_____________//访问局部变量
this. size++; //访问内部类的成员变量
_____________//访问外部类的成员变量
System.out.println(size+" "+this.size+" "+Outer.this.size);
public void taskInner()
___________
k.doSomething(8);
private static int size;
参考答案:
size++; Outer.this.size++: Inner k=new Inner();问题解析:
本题主要考查内部类的概念,super,this关键字的用法。解答本题的关键是熟练掌握super, this关键字的用法。在本题中size++;语句是访问局部变量size,Outer.this.size++;语句的功能是访问外部类的成员变量size,InnerK=new Inner();语句的功能是生成内部类Inner的对象K。

![[问答题] 请在每条横线处填写一个语句,使程序的功能完整,且输出结果为91 1。 注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 源程序文件代码清单如下: pu [问答题] 请在每条横线处填写一个语句,使程序的功能完整,且输出结果为91 1。 注意:请勿改动main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 源程序文件代码清单如下: pu](http://www.mshxw.com/aiimages/31/259425.png)
