Vidyalelo
Java Programming · Q2

Data Types and Variables

Programming · Java Programming · question 2

Q2

Which data type is used to store a single character in Java?

A.
char
Answer
B.
string
C.
letter
D.
ch

Answer: Option A

Solution

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

In Java, the char data type is used to store a single character. It can hold any single Unicode character, including letters, digits, and special symbols.

Using char allows you to store individual characters like 'A', '7', '$', etc., whereas String (Option B) is used to store a sequence of characters (a string of characters).

Options C and D are not valid data types in Java.