public class AQuestion
{
private int i = giveMeJ();
private int j = 10;
private int giveMeJ()
{
return j;
}
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 Compilation error - The output is 0;
d.No Compilation error - The output is 10;
IMO answer should be d. But the answer given is c. Can anybody explain.