English

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?
Chapter 5: Primitive Values, Wrapper Classes, Types and Casting - EXERCISE [Page 112]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 5 Primitive Values, Wrapper Classes, Types and Casting
EXERCISE | Q 4. (g) | Page 112
Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 6. | Page 131
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×