This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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.
 
Consider Paul's rocket mass heater.
 
subject: static method