Q2
Which data type is used to store a single character in Java?
A.
char
AnswerB.
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.