File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static method