Which of the following is not a primitive data type in Java?
A. int
B. byte
C. char
D. string
Answer: Option D
Solution(By Examveda Team)
The correct answer is Option D: string.In Java, a primitive data type is a basic data type that represents a single value. The primitive data types in Java are int, byte, and char among the options provided.
Here's the breakdown:
Option A: int - This is a primitive data type in Java used for representing whole numbers (integers).
Option B: byte - This is also a primitive data type in Java used for representing small integers.
Option C: char - This is a primitive data type in Java used for representing single characters.
Option D: string - This is not a primitive data type in Java. Instead, it is a class (String class) used to represent sequences of characters. String objects are not primitives because they are more complex and can have methods and properties.
So, among the provided options, string is not a primitive data type in Java.
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