*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "John Hunt Question 62" Watch "John Hunt Question 62" New topic
Author

John Hunt Question 62

Melissa Ting
Greenhorn

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); {
sample();
}
}
}
private boolean flag = false;
public void sample() {
System.out.println("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
 
Similar Threads
this
Que on JohnHunt exam
Hunt Exam Question
A question of JTest.
inner class question from HUNT