Examveda
Examveda

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.

This Question Belongs to Java Program >> Data Types And Variables

Join The Discussion

Related Questions on Data Types and Variables