Java Data Types MCQ - Multiple Choice Questions And Answers
Q. Which of the following is a primitive data type in Java?
A. IntegerB. String
C. Double
D. Array
Q. Which of the following is not a Java data type?
A. BooleanB. Character
C. String
D. Object
Q. What is the size of the boolean data type in Java?
A. 8 bitsB. 16 bits
C. 32 bits
D. It depends on the Java version and platform
Q. Which of the following is not a valid identifier for a variable in Java?
A. myVariableB. 123variable
C. _myVariable
D. $variable
Q. Which of the following data types has the highest range of values in Java?
A. byteB. int
C. long
D. double
Q. Which of the following is the correct syntax for declaring an array in Java?
A. int arrayName[10];B. int[arrayName] = new int[10];
C. int[] arrayName = new int[10];
D. intArray arrayName = new int[10];
Q. What is the default value of a boolean variable in Java?
A. trueB. false
C. 0
D. null
Q. Which of the following is a floating-point data type in Java?
A. intB. double
C. char
D. boolean
Q. What is the purpose of the `boolean` data type in Java?
A. To store whole numbersB. To store decimal numbers
C. To store true or false values
D. To store characters
Q. Which keyword is used to declare a constant variable in Java?
A. constantB. final
C. static
D. abstract
Q. What is the correct data type to store a whole number in Java?
A. intB. double
C. String
D. boolean
Q. What is the correct syntax to declare a variable of type double in Java?
A. int myVariable;B. double myVariable;
C. String myVariable;
D. boolean myVariable;
Q. What is the default value of a variable of type boolean in Java?
A. trueB. false
C. Undefined
D. null