• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Que on JohnHunt exam

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How is line #1 is executed. The value for Test4.this.flag would be false .
Am i right? or am i missing something out here...
-Sanjana
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi sanjana, note the semi-colon at the end of the if-stat.

That is why sample() is executed regardlass the if-stat.
Hope this helps.
[ January 04, 2004: Message edited by: Vicken Karaoghlanian ]
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Btw shouldn't class Test4 be declared static so you can call it directly like is mentionned ??
if (Test4.this.flag); {//1
 
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kristof,
Great question! I was stumped on that myself.
The answer can be found in the JLS at15.8.4
It's a 'qualified this' reference. An enclosed class can refer to members of it's enclosing class via <Enclosing Class Name>.this.<member>
Interestingly enough, the depth of the inner class doesn't seem to matter:

o/p:
I : false
II : true
II : false

Thank You
 
Are you okay? You look a little big. Maybe this tiny ad will help:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic