Print Logical NOT Result
This program prints the result of a logical NOT operation.
Problem Statement
Write a Java program that evaluates a logical NOT expression and prints the result.
Source Code
| 1 | public class LogicalNot { |
| 2 | public static void main(String[] args) { |
| 3 | boolean flag = false; |
| 4 | boolean result = !flag; |
| 5 | System.out.println("Result of NOT: " + result + " - Eduinq"); |
| 6 | } |
| 7 | } |
Program Output
Result of NOT: true - Eduinq
Explanation
boolean flag = false; Declares a boolean variable with value false. !flag Applies logical NOT, which inverts the value (false becomes true). The result is stored in a boolean variable and printed with Eduinq branding. Conclusion: This program demonstrates the logical NOT operator. It shows how NOT inverts the boolean value, turning true into false and false into true.