Search Tutorials


Java Data Types MCQ - Multiple Choice Questions And Answers | JavaInUse

Java Data Types MCQ - Multiple Choice Questions And Answers

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

A. Integer
B. String
C. Double
D. Array

Q. Which of the following is not a Java data type?

A. Boolean
B. Character
C. String
D. Object

Q. What is the size of the boolean data type in Java?

A. 8 bits
B. 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. myVariable
B. 123variable
C. _myVariable
D. $variable

Q. Which of the following data types has the highest range of values in Java?

A. byte
B. 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. true
B. false
C. 0
D. null

Q. Which of the following is a floating-point data type in Java?

A. int
B. double
C. char
D. boolean

Q. What is the purpose of the `boolean` data type in Java?

A. To store whole numbers
B. 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. constant
B. final
C. static
D. abstract

Q. What is the correct data type to store a whole number in Java?

A. int
B. 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. true
B. false
C. Undefined
D. null





Q. Which data type is used to store a single character in Java?

A. char
B. double
C. String
D. boolean

Q. What is the correct syntax to declare a variable of type String in Java?

A. int myVariable;
B. double myVariable;
C. String myVariable;
D. boolean myVariable;

Q. What is the correct syntax to declare a variable of type boolean in Java?

A. int myVariable;
B. double myVariable;
C. String myVariable;
D. boolean myVariable;

Q. Which of the following is not a valid Java data type?

A. int
B. double
C. float
D. string

Q. What is the size of the int data type in Java?

A. 4 bytes
B. 8 bytes
C. 2 bytes
D. 1 byte

Q. What is the size of the double data type in Java?

A. 4 bytes
B. 8 bytes
C. 2 bytes
D. 1 byte