What is a datatype?

Short Answer
Views 86

Answer:

  • A datatype defines what kind of data a variable can hold in Java.

  • Example:


int age = 25;       // age can store integer values
double salary = 5000.50; // salary can store decimal values
char grade = 'A';   // grade stores a single character
boolean isPassed = true; // stores true/false

Java datatypes are mainly two categories:

  • Primitive typesint, double, boolean, char, byte, short, long, float

  • Reference types → classes, arrays, interfaces, enums, etc.

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.