IntelliJ Java IDE
The moose likes Mock Exam Errata and the fly likes Angelfire.com....quiz 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Mock Exam Errata
Reply Bookmark "Angelfire.com....quiz 2" Watch "Angelfire.com....quiz 2" New topic
Author

Angelfire.com....quiz 2

Mukti Bajaj
Ranch Hand

Joined: Dec 11, 2000
Posts: 59
Hi,
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
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 answer to the question above is 3. But, can someone explain the reason.......
Thanks.

bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
As the correct answer is C, I am going to move this over to Java Certfication Study where you will get a better response. This question has been talked about a few times in that forum, so you may want to do a search.
Bill
 
 
subject: Angelfire.com....quiz 2
 
Threads others viewed
Angelfire.com....quiz 2
Access Modifiers
Abilash's mock exam, #11
order of loading??????
Doubt
developer file tools