Which of the following is NOT a primitive data type in Java?
A
int B
boolean C
String D
double
Analysis & Theory
`String` is a class in Java, not a primitive data type.
Which data type is used to store whole numbers in Java?
A
int B
double C
boolean D
char
Analysis & Theory
`int` is used to store integers (whole numbers).
Which Java data type is used to store true or false values?
A
int B
boolean C
byte D
char
Analysis & Theory
`boolean` stores only two possible values: `true` or `false`.
What is the default value of a `boolean` in Java (for instance variables)?
A
true B
false C
0 D
null
Analysis & Theory
`boolean` instance variables default to `false` if not initialized.
Which data type would you use to store a single letter like 'A'?
A
String B
char C
boolean D
byte
Analysis & Theory
`char` is used to store single characters enclosed in single quotes.
Which data type has the largest memory size?
A
int B
long C
double D
float
Analysis & Theory
`double` occupies 8 bytes and has a larger range than the others listed.
Which of the following is a floating-point data type?
A
int B
float C
byte D
boolean
Analysis & Theory
`float` stores decimal numbers using 4 bytes.
What is the size of a `byte` in Java?
A
1 bit B
1 byte C
2 bytes D
4 bytes
Analysis & Theory
`byte` is the smallest integer data type and uses exactly 1 byte (8 bits).
What is the default value of a `char` variable (as an instance variable)?
A
'\0' B
' ' (space) C
null D
0
Analysis & Theory
The default value of `char` is the null character: `'\0'`.
Which data type is best suited for storing a person's salary (e.g., 50000.75)?
A
int B
float C
char D
double
Analysis & Theory
`double` provides higher precision for decimal numbers and is commonly used for currency values.