Which of the following is a primitive data type in Java?
A. String
B. Integer
C. Boolean
D. Char
Answer: Option D
Solution(By Examveda Team)
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.
Related Questions on Data Types and Variables
What is the maximum value that can be stored in a byte variable in Java?
A. 127
B. 255
C. 32767
D. 64
What is the default value of an int variable in Java if it's not explicitly initialized?
A. 0
B. 1
C. -1
D. Null
Which of the following is not a valid identifier for a Java variable?
A. my_var
B. _myVar
C. 3rdVar
D. $var
Join The Discussion