aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes boolean question  from John Junt Mock Exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "boolean question  from John Junt Mock Exam" Watch "boolean question  from John Junt Mock Exam" New topic
Author

boolean question from John Junt Mock Exam

may leung
Greenhorn

Joined: Nov 28, 2000
Posts: 23
boolean flag = false;
if (flag = true) {
System.out.println("true");
} else {
System.out.println("false");
}
a true is printed to standard out
b false is printed to standard out
c An exception is raised
d Nothing happens
The ans is d, But I think the ans should be A. Can anyone tell me the true?
sasi dhulipala
Ranch Hand

Joined: Dec 28, 2000
Posts: 31
true is being printed on my sys. because the if statement
if (flag = true) is assigning true to flag and the enitre value of the expression becomes true making if to pass through and print
"true".

Sasidhar

[This message has been edited by sasi dhulipala (edited January 09, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: boolean question from John Junt Mock Exam