jQuery in Action, 3rd edition
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 Java Interview Guide this week in the Jobs Discussion 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: http://aspose.com/file-tools
subject: John Hunt Question 62
It's not a secret anymore!