Java Boolean Default Value | Generated by AI
Question: What is the default value of a boolean instance variable in a class?
Answer:
In Java, instance variables (fields) of a class that are not explicitly initialized are automatically assigned default values based on their type.
For primitive types:
booleandefaults to falseint,byte,short,longdefault to 0float,doubledefault to 0.0chardefaults to ββ (null character)- Reference types (e.g., objects, strings) default to
null
Therefore, the default value of a boolean instance variable is false.
The correct answer is B. false.
Note: This applies to instance variables and static variables. Local variables (declared inside methods) do not have default values and must be explicitly initialized before use.
References: