What is the number of bytes used by Java primitive long?
-
The number of bytes is compiler dependent
-
2
-
4
-
8
Java primitive types have fixed sizes across all platforms. The long primitive is always 8 bytes (64 bits), unlike C/C++ where sizes may vary by compiler and platform.
To answer this question, we need to understand the size of the Java primitive data type "long."
The Java primitive data type "long" is a 64-bit signed integer. It can hold values ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
In Java, the size of a "long" data type is always 8 bytes. This is because the Java language specification defines "long" as a 64-bit data type, which means it requires 8 bytes of memory to store its value.
Therefore, the correct answer is:
D. 8