Logical Equivalence Analysis
A program tests the truth value of a statement derived from De Morgan’s Law to verify logical equivalence.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void main(String[] args) {
boolean p = true;
boolean q = false;
boolean res = !(p || q) == (!p && !q);
System.out.print(res);
}
}
A
true
B
1
C
0
D
false
Question Leaderboard
Not enough data yet to show leaderboard.
