This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes John Hunt Question 62 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "John Hunt Question 62" Watch "John Hunt Question 62" New topic

John Hunt Question 62

Melissa Ting

Joined: Jun 14, 2002
Posts: 3
Hi there...
I have a silly questions. Please be patient with me. I don't understand why it will print Sample becuase I thought that the flag = false. Since it's false how come it will execute sample.
Thanks in advance.

Q. 62
Examine the following code which includes an inner class:

public final class Test4 implements A {
class Inner {
void test() {
if (Test4.this.flag); {
private boolean flag = false;
public void sample() {
public Test4() {
(new Inner()).test();
public static void main(String args []) {
new Test4();

What is the result:
A. Prints out "Sample"
B. Program produces no output but terminates correctly.
C. Program does not terminate.
D. The program will not compile
Paul Villangca
Ranch Hand

Joined: Jun 04, 2002
Posts: 133
Notice the semicolon (;) just after your if statement. That should make everything clear.
Heh, silly me, there's a smiley in my post.
[ June 19, 2002: Message edited by: Paul Villangca ]
I agree. Here's the link:
subject: John Hunt Question 62
jQuery in Action, 3rd edition