What will the following code print out:

public class Test {
    public static boolean methodOne() {
        System.out.println("methodOne ");
        return false;
    }

    public static boolean methodTwo() {
        System.out.println("methodTwo ");
        return true;
    }

    public static boolean methodThree() {
        System.out.println("methodThree ");
        return true;
    }

    public static void main(String[] args){
        System.out.println(Test.methodOne() || Test.methodTwo() || Test.methodThree());
    }
}
Explanation
This question deals with the so-called "accelerated computing" phenomenon in the process of work with logical expressions. The methodThree method will not be called since the result of the expression does not depend on it.
"methodOne" and "methodTwo" lines will be displayed during the evaluation of the expression's value and the value of the expression itself (true) will be displayed later.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes