• 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!