Correct option is B
In Java, static variables belong to the class rather than an instance and are initialized with default values if not explicitly set. For int variables, the default value is 0.
Example:
Important Key Points:
1. Default values for static variables are determined by the type:
· int: 0
· double: 0.0
· boolean: false
· Object references: null
2. static variables are stored in the
method area of the JVM.
Knowledge Booster:
·
null: Applicable for object references, not primitive types.
·
-1: Not the default value for any type in Java.
·
undefined: Java does not use the concept of "undefined"; default values are well-defined.
·
garbage value: Java does not allow uninitialized variables to have garbage values.