Multiple choice technology programming languages

What is the number of bytes used by Java primitive long?

  1. The number of bytes is compiler dependent

  2. 2

  3. 4

  4. 8

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

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.

AI explanation

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