Vidyalelo
Java Programming · Q10

Data Types and Variables

Programming · Java Programming · question 10

Q10

Which of the following is a primitive data type in Java?

A.
String
B.
Integer
C.
Boolean
D.
Char
Answer

Answer: Option D

Solution

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

In Java, a primitive data type is a basic data type that is not an object. char is one of the primitive data types in Java, used to store a single character, such as 'A' or '5'.

Here's the breakdown:

Option A: String - String is not a primitive data type in Java. It is a class for representing sequences of characters.

Option B: Integer - Integer is not a primitive data type, but int (lowercase) is a primitive data type used to store whole numbers.

Option C: Boolean - Boolean is not a primitive data type, but boolean (lowercase) is a primitive data type used to represent true or false values.

Option D: Char - This is the correct answer. char is a primitive data type in Java used to store a single character.

So, the primitive data type in Java among the given options is char.