| Author |
Forward reference
|
Srinivas Kumar
Ranch Hand
Joined: Jul 14, 2005
Posts: 52
|
|
public class AQuestion { private int i = j; private int j = 10; public static void main(String args[]) { System.out.println((new AQuestion()).i); } } Answers a)Compiler error complaining about access restriction of private variables of AQuestion. b)Compiler error complaining about forward referencing. c)No error - The output is 0; d)No error - The output is 10; answer is given as b. can anybody explain?
|
 |
Srinivas Kumar
Ranch Hand
Joined: Jul 14, 2005
Posts: 52
|
|
Got the answer from the following link http://radio.javaranch.com/corey/2004/05/13/1084483439000.html
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
See Corey's Tipline on Forward Referencing.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
 |
|
|
subject: Forward reference
|
|
|