Explain the char Data Type with an Example.
Advertisements
Question
Explain the char Data Type with an Example.
Explain
Advertisements
Solution
The char data type is a primitive data type in Java that is used to store a single character, such as a letter, digit or special symbol. It is a 16-bit unsigned data type that occupies 2 bytes of memory. It stores characters using the Unicode character set, with values ranging from 0 to 65,535.
Example:
char grade = 'A';
In the above example, char specifies the data type, grade is the variable name, and 'A' is the character value assigned to the variable.
shaalaa.com
Is there an error in this question or solution?
