File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Confused Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Confused" Watch "Confused" New topic
Author

Confused

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Can anybody explain me why the answer is B,SuperB,A,SuperA
This is a question in Dans mock exam and i guess theres been some error here in code as i feel line 5 doesn't make any sense

Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
Hi Mary,
In line 6 the inner class B and it's enclosing class
A are instantiated and m1() is invoked immediately.
In line 2 this refers to the instance of the inner
class; in line 3 super refers to the superclass (SuperB)
of the inner class and in particular to the value of s1;
in line 4 A.this.s1 refers to the instance of the enclosing
class A and in particular the value of s1.
And coming back to your question line 5 refers to the
superclass of the enclosing class A (SuperA) and in
particular to the value of s1.
Instances of class A are always instances of (instanceof)
class A or SuperA.
class B has no other relationship with A than being
it inner class. With this I mean that it doesn't
extend in any way class A. And can't be an instanceof
A.

Was I clear? Best Regards,

Gian Franco Casula
p.s. the code compiles with no hitches
[ February 26, 2004: Message edited by: Gian Franco Casula ]

"Eppur si muove!"
Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Thx,
I missed that it was an innerclass........oversight
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confused