Which statements are true about the lines of output printed by the following program?.
public class Main { static void op(boolean a, boolean b) { boolean c = a != b; boolean d = a ^ b; boolean e = c == d; System.out.println(e);/*w w w. ja v a 2 s. c o m*/ } public static void main(String[] args) { op(false, false); op(true, false); op(false, true); op(true, true); } }
Select the three correct answers.
(a), (c), and (e)
The != and ^ operators, when used on boolean operands, will return true if and only if one operand is true, and false otherwise.
This means that d and e in the program will always be assigned the same value, given any combination of truth values in a and b.
The program will, therefore, print true four times.