Explain the Boolean data type with an Example.
Advertisements
Question
Explain the Boolean data type with an Example.
Explain
Advertisements
Solution
The boolean data type is a primitive data type in Java that is used to store logical values. It can store only two values: true or false. It is mainly used in conditional statements, comparisons and decision-making operations.
Example:
boolean isPassed = true;
In the above example, boolean specifies the data type, isPassed is the variable name, and true is the logical value assigned to the variable.
shaalaa.com
Is there an error in this question or solution?
