What is the size of a long variable in Java?
A. 4 bytes
B. 8 bytes
C. 2 bytes
D. 16 bytes
Answer: Option B
Solution(By Examveda Team)
The correct answer is Option B: 8 bytes.In Java, a long variable is used to store large integer values, and it occupies 8 bytes of memory.
Here's the breakdown:
Option A: 4 bytes - This size corresponds to the int data type in Java, not long.
Option B: 8 bytes - This is the correct size for a long variable in Java.
Option C: 2 bytes - This size corresponds to the short data type in Java, not long.
Option D: 16 bytes - There is no standard long data type that occupies 16 bytes in Java.
So, the size of a long variable in Java is 8 bytes.
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