Java Primitive Data Types

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Catherine Halcomb
Catherine Halcomb
Community Contributor
Quizzes Created: 3100 | Total Attempts: 6,949,905
| Questions: 10 | Updated: Sep 8, 2026
Please wait...
Question 1 / 11
🏆 Rank #--
0 %
0/100
Score 0/100

1. What is the range of the `short` primitive data type in Java?

Explanation

In Java, the `short` primitive data type is a 16-bit signed integer. This means it can represent values from -2^15 to 2^15 - 1. The minimum value, -2^15, equals -32,768, and the maximum value, 2^15 - 1, equals 32,767. This range allows for efficient memory usage while still accommodating a wide variety of integer values, making `short` suitable for applications where memory is a constraint.

Submit
Please wait...
About This Quiz
Java Primitive Data Types - Quiz

This assessment focuses on Java primitive data types, evaluating your understanding of types like int, short, and long. It covers essential concepts such as data type ranges, declarations, and the distinction between primitive and reference types. Mastering these topics is crucial for effective Java programming and helps in building a... see moresolid foundation for further learning. see less

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which of the following correctly declares and initializes a `long` variable in Java?

Explanation

In Java, a `long` variable can be declared and initialized using either an uppercase 'L' or a lowercase 'l' suffix to indicate that the literal is of type long. While both `long myLong = 123456789L;` and `long myLong = 123456789l;` are valid, it's generally recommended to use the uppercase 'L' to avoid confusion with the number '1'. Thus, both options b and c correctly declare and initialize a `long` variable.

Submit

3. How many bits does the `int` primitive data type use in Java?

Explanation

In Java, the `int` primitive data type is designed to hold integer values and is consistently allocated 32 bits of memory. This allows it to represent a wide range of integer values, specifically from -2,147,483,648 to 2,147,483,647. The 32-bit size is a standard in Java, ensuring that integers are managed efficiently across different platforms and systems. This fixed size contributes to Java's portability, allowing developers to write code that behaves consistently regardless of the underlying hardware.

Submit

4. Which of the following is NOT a primitive data type in Java?

Explanation

In Java, primitive data types include boolean, char, double, and others that represent simple values. However, "string" is not a primitive data type; instead, it is a reference type that represents a sequence of characters. While strings are widely used in Java programming, they are part of the Java Standard Library and require an object to manage their functionality, distinguishing them from the primitive types that hold their values directly.

Submit

5. What suffix must be appended to a literal value when assigning it to a `long` variable in Java to avoid a compile-time error?

Explanation

In Java, when assigning a literal value to a `long` variable, it is necessary to append the suffix 'L' or 'l' to indicate that the literal should be treated as a long integer rather than the default int type. This distinction prevents compile-time errors that occur when a long value is expected but an int is provided. Using 'L' is a best practice as it enhances code readability and avoids confusion with the lowercase 'l', which can be mistaken for the number 1.

Submit

6. Which Java data type would you use to store the value -9,223,372,036,854,775,000?

Explanation

In Java, the `long` data type is a 64-bit signed integer, capable of storing values ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. The value -9,223,372,036,854,775,000 falls within this range, making `long` the appropriate choice. In contrast, `int` (32-bit) and `short` (16-bit) cannot accommodate such large numbers, and `byte` (8-bit) is even smaller. Therefore, when dealing with large integers like -9,223,372,036,854,775,000, `long` is the suitable data type in Java.

Submit

7. In Java, `String` is classified as a ______ type, not a primitive type.

Explanation

In Java, `String` is classified as a reference type because it represents an object that holds a sequence of characters, rather than being a basic data type like int or char. Reference types store the memory address of the object rather than the actual data itself. This allows for more complex data manipulation and functionality, such as methods for string manipulation. Unlike primitive types, which hold their values directly, reference types enable the use of objects with properties and behaviors, making them more versatile in programming.

Submit

8. The `int` data type in Java is a signed 64-bit integer.

Explanation

In Java, the `int` data type is a signed 32-bit integer, not a 64-bit integer. This means it can represent values from -2,147,483,648 to 2,147,483,647. The 64-bit integer in Java is represented by the `long` data type, which can store a much larger range of values. Understanding these distinctions is crucial for effective memory management and data handling in Java programming.

Submit

9. Which of the following are Reference Types in Java?

Explanation

In Java, reference types store references to objects rather than the actual data values. Objects are instances of classes, strings are sequences of characters treated as objects, and arrays are also objects that hold multiple values. In contrast, `int` is a primitive type that directly holds numeric values, not a reference. Thus, object, string, and array are all classified as reference types, while int is not.

Submit

10. Match each Java primitive data type with its correct bit size.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What is the range of the `short` primitive data type in Java?
Which of the following correctly declares and initializes a `long`...
How many bits does the `int` primitive data type use in Java?
Which of the following is NOT a primitive data type in Java?
What suffix must be appended to a literal value when assigning it to a...
Which Java data type would you use to store the value...
In Java, `String` is classified as a ______ type, not a primitive...
The `int` data type in Java is a signed 64-bit integer.
Which of the following are Reference Types in Java?
Match each Java primitive data type with its correct bit size.
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!