Default boolean value in java

In this article, we will learn about the default value of a boolean keyword in java. This primitive data type can have only two possible values i.e. true and false. Generally, this data type is used in java programming to check or handle the true/false conditional check.

So don’t waste your time and continue reading this article thoroughly to clear all your doubts related to boolean data type default value.

What is mean by the default value of a variable?

A default value is an initial value assigned to a variable when it is not initialized in the program. Like default value for the int data type is 0, if you don’t initialize it.

What is default boolean value in java?

The default boolean value in java is false

In java programming false is stored as 0 and true is stored as 1 in the database.

false –> 0

true –> 1

How to check default boolean value in java?

In the below example we have printed the value of a boolean variable that is not initialized. So t will print the default value assigned to it.

package com.technolads;

public class Technolads_Test 
    //Declare boolean variable  
    static boolean testVariable;
    public static void main(String[] args) 
        System.out.println("Boolean variable default value is: " + testVariable);


Following is the output of the above program.

Boolean variable default value is: false


In this article, we studied what is the default boolean value in java and how you can check.

We hope this article was informative and you got a clear idea about the boolean data type. If you need further clarification on any of the above points then please do mention it in the comment section or you can reach out to us using Contact Form.

Frequently asked questions:

What is the difference between boolean and Boolean in java?

boolean is a primitive data type and its default value is false.

Boolean is a wrapper class and the default value of its object is null.

How to set an initial value for a boolean variable in java?

You can set the initial value as true of a boolean variable as shown below:

boolean testBooleanVariable = true;

What is the size of a boolean data type?

The precise size of a boolean variable is not mentioned in the java specification. It depends on the Java Virtual Machine on which the java application is running.

Leave a Comment