Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static method 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 "static method" Watch "static method" New topic
Author

static method

jay lai
Ranch Hand

Joined: Apr 04, 2002
Posts: 180
I got this question in Marcus Green mock exam:

public class Ombersley{
public static void main(String argv[]){
boolean b1 = true;
if((b1 ==true) || place(true)){
System.out.println("Hello Crowle");
}
}

public static boolean place(boolean location){
if(location==true){
System.out.println("Borcetshire");

}
System.out.println("Powick");

return true;
}
}

The answer is Hello Crowle
Would anyone pls explain, is that b/c the static boolean method.
Thanks
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by jay lai:
...The answer is Hello Crowle
Would anyone pls explain, is that b/c the static boolean method...

It's because of the short-circuiting "or" ( || ).

(b1==true) evaluates to true, and so place(true) is not evaluated.

Does that make sense?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
jay lai
Ranch Hand

Joined: Apr 04, 2002
Posts: 180
Yes: it does
thanks for response.
 
 
subject: static method
 
Similar Threads
Unable to understand result of this code
Boolean doubt
Core java
Marcus Green, wrong wrong answer
Associativity and precedence of Conditional operators