You are here: Home / Topics / Explain different data types in Java.

Explain different data types in Java.

Filed under: Java Interview Questions on 2024-10-25 14:32:31

There are 2 types of data types in Java as mentioned below:

  1. Primitive Data Type
  2. Non-Primitive Data Type or Object Data type

Primitive Data Type: Primitive data are single values with no special capabilities. There are 8 primitive data types:

  • boolean: stores value true or false
  • byte: stores an 8-bit signed two’s complement integer
  • char: stores a single 16-bit Unicode character
  • short: stores a 16-bit signed two’s complement integer
  • int: stores a 32-bit signed two’s complement integer
  • long: stores a 64-bit two’s complement integer
  • float: stores a single-precision 32-bit IEEE 754 floating-point
  • double: stores a double-precision 64-bit IEEE 754 floating-point

Non-Primitive Data Type: Reference Data types will contain a memory address of the variable’s values because it is not able to directly store the values in the memory. Types of Non-Primitive are mentioned below:

  • Strings
  • Array
  • Class
  • Object
  • Interface
About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.