Data Types

Practice commonly asked Data Types interview questions with clear answers and explanations.

6 Interview Questions

Data Types Interview Questions

6 Questions
Q 61

What is the size and range of long in Java?

Easy
Answer
long is a 64-bit signed integer with a range from -2^63 to 2^63 - 1.
Explanation
Use long when integer values may exceed the range of int, such as large identifiers, counters, or timestamps.
Reference: Java Language Specification
Q 62

What is the size and range of int in Java?

Easy
Answer
int is a 32-bit signed integer with a range from -2,147,483,648 to 2,147,483,647.
Explanation
int is the default integral type for most ordinary integer calculations in Java.
Reference: Java Language Specification
Q 63

What is the size and range of short in Java?

Easy
Answer
short is a 16-bit signed integer with a range from -32,768 to 32,767.
Explanation
It occupies less memory than int and is sometimes useful when representing compact numeric data, although arithmetic expressions are generally promoted to int.
Reference: Java Language Specification
Q 64

What is the size of byte in Java?

Easy
Answer
A byte is an 8-bit signed integer type with a range from -128 to 127.
Explanation
byte is useful when working with raw binary data or when memory efficiency is important for large arrays.
Reference: Java Language Specification
Q 65

What is the difference between primitive and reference data types?

Easy
Answer
A primitive variable stores a value directly, while a reference variable stores a reference to an object or array.
Explanation
Reference types can represent objects and arrays and can have the value null. Primitive variables cannot hold null unless their values are wrapped in corresponding wrapper classes.
Reference: Java Language Specification
Q 66

What are the eight primitive data types in Java?

Easy
Answer
Java has eight primitive data types: byte, short, int, long, float, double, char, and boolean.
Explanation
Primitive types represent simple values directly and are not objects. They have predefined sizes and value ranges defined by the Java language.
Reference: Java Language Specification

About This Topic

Prepare for Data Types interviews with important concepts and commonly asked questions.