ExamVeda
Login
Home
Data Types and Variables
?

What is the size of a long variable in Java?

Answer & Solution
Correct Answer: Option B
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.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.