Vidyalelo
Java Programming · Q17

Data Types and Variables

Programming · Java Programming · question 17

Q17

What is the default value of a double variable in Java if it's not explicitly initialized?

A.
0
Answer
B.
1
C.
-1
D.
Null

Answer: Option A

Solution

Answer: Option A
Solution:
The correct answer is Option A: 0.

In Java, the default value of a double variable is 0.0 if it's not explicitly initialized.

Here's the breakdown:

Option A: 0 - This is the correct default value for an uninitialized double variable in Java. It represents the numeric value zero.

Option B: 1 - This is not the default value for a double variable. The default is 0.0, not 1.0.

Option C: -1 - This is not the default value for a double variable. The default is 0.0, not -1.0.

Option D: Null - Null is not a valid value for a double variable. Java uses 0.0 as the default value for uninitialized double variables.

So, the default value of a double variable in Java if it's not explicitly initialized is 0.0.