Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

inner class visibility  RSS feed

 
nalamati satyanarayana
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


No one will help you answer that question.

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

/Svend Rost
 
Campbell Ritchie
Marshal
Posts: 55799
164
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!