What is the default value of a char variable in Java if it's not explicitly initialized?
A. ' '
B. '0'
C. '\u0000'
D. Null
Answer: Option C
Solution(By Examveda Team)
The correct answer is Option C: '\u0000'.In Java, the default value of a char variable is '\u0000' (Unicode character with code point 0) if it's not explicitly initialized.
Here's the breakdown:
Option A: ' ' - This represents a space character, but it is not the default value for an uninitialized char variable.
Option B: '0' - This represents the character '0', but it is not the default value for an uninitialized char variable.
Option C: '\u0000' - This is the correct default value for an uninitialized char variable in Java. It represents the Unicode character with the code point of zero.
Option D: Null - Null is not a valid value for a char variable. The default value is '\u0000', not Null.
So, the default value of a char variable in Java if it's not explicitly initialized is '\u0000'.
Related Questions on Data Types and Variables
What is the maximum value that can be stored in a byte variable in Java?
A. 127
B. 255
C. 32767
D. 64
What is the default value of an int variable in Java if it's not explicitly initialized?
A. 0
B. 1
C. -1
D. Null
Which of the following is not a valid identifier for a Java variable?
A. my_var
B. _myVar
C. 3rdVar
D. $var
Join The Discussion