From abHilash's
java quiz site:
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);
}
}
1. Compiler error complaining about access restriction of private variables of AQuestion.
2. Compiler error complaining about forward referencing.
3. No Compilation error - The output is 0;
4. No Compilation error - The output is 10;
The correct answer is:3
I thought 4 is correct. when I compiled and run it gave the output is: 0. Can someone explain why the output is :0?
Thanks
VR