Given code:

public class A {
    public static void main(String[] args) {
        boolean a = true;
        boolean b = false;
        boolean c = true;
        if (a || b && c)
        System.out.print("Hello ");
        if (a && !b && c)
        System.out.print("World");	
    }
}
What will be displayed on the console?
Explanation
a || b && c = 
true || false && true = true || false = true

a && !b && c = 
true && !false && true = true && true && true == true

Follow CodeGalaxy

Mobile Beta

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