This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Confused  RSS feed

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx,
I missed that it was an innerclass........oversight
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!