Examveda
Examveda

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'.

This Question Belongs to Java Program >> Data Types And Variables

Join The Discussion

Related Questions on Data Types and Variables