What is the default value of a boolean in Java?

Java MCQ: What is the default value of a boolean in Java?

a) true
b) false
c) 0
d) null

Answer:

b) false

Explanation:

The default value of a boolean variable in Java is false. When a boolean variable is declared but not initialized, it automatically takes the value of false.

Knowing the default values of data types is essential for avoiding unexpected behavior in your Java programs.

Reference links:

https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top