[code]
public class NormClass {
long startTime ;
public class NestedClass {
// methods and variables of NestedClass
}
// other methods and variables of NormClass
}
Which of the following can be used by a method inside NestedClass to refer to the startTime variable in the enclosing instance of NormClass?
A
this.startTime
B
NormClass.this.startTime
C
this.NormClass.startTime
D
startTime
[code]
I have come across with this sort of question several times but answers are inconsistent.
The actual answer what I think are B and D. But in case the inner class has already a member named startTime, then simply writing startTime wont get you outer class startTime. In this regard option "B" is the only correct answer.
What should I suppose before answering this kind of questions? Should I look for inner class, where it has a member named startTime or NOT?
Please guide...
Source Thanks,
[EDITED] Post edited one Keith's reminder regarding answer 'C' [ May 01, 2007: Message edited by: Chandra Bhatt ]
[ May 01, 2007: Message edited by: Chandra Bhatt ]