Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

inner class visibility

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class Outside {
2
3 private int a;
4
5 public void foo(int b) {
6 int c = a;
7 int d = b;
11 }
8 class Inside {
9 public Inside() {
10 // What can I see here?
12 }
13 Inside e = new Inside();
14 }
15
16 }
Question Which variable is visible at line 10 above?
Choice 1
a
Choice 2
b
Choice 3
c
Choice 4
d
Choice 5
e
 
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


No one will help you answer that question.

If you dont make an effort.. we wont either.

/Svend Rost
 
Marshal
Posts: 74687
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Posted by Svend Rost

No one will help you answer that question.

Agree. The correct answer is of course, "f."



You will have to put something like "System.out.println(a)" in line 10 and keep trying until it compiles. And also see what happens if you actually run it.
reply
    Bookmark Topic Watch Topic
  • New Topic