Sree,See carefully.
1)It must implemet an interface.
false. The 'must' makes the statement false. We can have a simple inner class like the foll.
<pre>
Example:
class Outer {
class Inner { //need not implement an interface
}
}
</pre>
2) It is accessible from any other class.
false. We can't generalize like this. The 'is accessible' makes the statement false. For example we can have a private inner class like the foll.
<pre>
Example:
class Outer {
private class Inner { //can't be seen outside
}
}
</pre>
3) It can only be instantiated in the enclosing class.
false. The 'only be instantiated in the enclosing ' all together makes the statement false. We can have inner class like the foll. and still can be instantiated outside of the class where it is defined.
<pre>
Example:
class Outer {
class Inner { }
}
class Test { //outsider class can make an instance of above inner
void m1() {
Outer.Inner outIn = new Outer().new Inner();
}
}
</pre>
4) It must be final if it is declared in a method scope.
false. need not be. we can have a local inner class like the foll.
<pre>
Example:
class Outer {
void m1() {
class LocalInner { //need not be final
}
}
}
</pre>
5) It can access private instance variables in the enclosing object.
true.The proof follows . At last one true statement
<pre>
Example:
class Outer {
private int privateVar=10;
class Inner {
Inner() {
System.out.println("See. I got your private data :"+Outer.this.privateVar);
}
}
}
</pre>
regds
maha anna
[This message has been edited by maha anna (edited April 19, 2000).]