Print Result of Boolean Expression
This program prints the result of a boolean expression.
Problem Statement
Write a Java program that evaluates a boolean expression and prints the result.
Source Code
| 1 | public class BooleanExpression { |
| 2 | public static void main(String[] args) { |
| 3 | boolean result = (10 > 5); |
| 4 | System.out.println("Is 10 greater than 5? " + result + " - Eduinq"); |
| 5 | } |
| 6 | } |
Program Output
Is 10 greater than 5? true - Eduinq
Explanation
The expression (10 > 5) is evaluated and stores true in the boolean variable result, which is printed with descriptive text, showing how boolean expressions can be evaluated and printed.