English

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?
Chapter 5: Primitive Values, Wrapper Classes, Types and Casting - EXERCISE [Page 112]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 5 Primitive Values, Wrapper Classes, Types and Casting
EXERCISE | Q 4. (f) | Page 112
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×