/*
面试题:
要求:
请填空分别输出30、20、10
class Outer{
public int num =10;
class Inner{
public int num = 20;
public void show(){
int num = 30;
System.out.println(?);
System.out.println(??);
System.out.println(???);
}
}
}
注意:
1:内部类和外部类没有继承关系。
2:通过外部类名限定this对象
Outer.this
*/
package cn.test;
class Outer{
public int num =10;
class Inner{
public int num = 20;
public void show(){
int num = 30;
System.out.println(num);
System.out.println(this.num);
//System.out.println(new Outer().num);
System.out.println(Outer.this.num);
}
}
}
class InnerClassTest{
public static void main(String[] args){
Outer.Inner oi = new Outer().new Inner();
oi.show();
}
}
面向对象_成员内部类的面试题
最新推荐文章于 2022-02-09 16:52:46 发布