I encountered this question on the JQ Mock Exam Application
What is printed when the following class is executed?
static boolean a;
static boolean b;
static boolean c;
public static void main (String args)
boolean bool = (a = true) || (b = true) && (c = true);
System.out.print(a + ", " + b + ", " + c);
The answer is true, false, false.
How is the statement boolean bool = (a = true) || (b = true) && (c = true);
I would think that first a is set to true. (b = true) is never evaluated because of the || statement and the fact that a is true. What I don't understand is why c is equals to false?