11.) What is the size of the char
data type in Java?
A) 1 byte
B) 2 bytes
C) 4 bytes
D) 8 bytes
12.) Which data type should be used to store true/false values when a single byte is sufficient?
A) byte
B) boolean
C) int
D) char
13.) What is the maximum value that can be stored in a long
data type in Java?
A) 2^31 – 1
B) 2^63 – 1
C) 2^32 – 1
D) 2^64 – 1
14.) Which data type should be used to store small whole numbers in Java to save memory?
A) short
B) long
C) double
D) byte
15.) Which data type should be used to represent a single Unicode character in Java?
A) String
B) char
C) Character
D) int
16.) What is the default value of a char
variable in Java?
A) ‘A’
B) ‘a’
C) 0
D) ‘\u0000’
17.) What is the scope of a local variable in Java?
A) It is accessible throughout the entire program.
B) It is accessible only within the method or block in which it is declared.
C) It is accessible within the same class and its subclasses.
D) It is accessible throughout the entire package.
18.) Which of the following is true about instance variables in Java?
A) They are declared with the “final” keyword.
B) They are static and shared among all instances of the class.
C) They are local variables declared within a method.
D) They are associated with an instance of a class and have unique values for each object.
19.) In Java, what is the purpose of declaring variables as “final”?
A) To make them constant and unchangeable.
B) To make them accessible globally.
C) To increase their visibility across different classes.
D) To allocate more memory for them.
20.) In Java, what is the naming convention for constant variables?
A) All uppercase letters are separated by underscores (e.g., MY_CONSTANT).
B) All lowercase letters are separated by underscores (e.g., my_constant).
C) CamelCase (e.g., MyConstant).
D) PascalCase (e.g., My_Constant).
Related