PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

Data Types in Java

← All stacks

Theory

11/270

Data Types in Java

A data type tells Java what kind of value a box can hold. There are primitives (raw values) and non-primitives (objects like String or your own class).

Eight primitives: byte, short, int, long, float, double, char, boolean. Day to day, use int for whole numbers and double for decimals. boolean is only true or false — not 0 and 1 like C.

String, arrays, and your classes are non-primitive. Bigger types can hold bigger numbers, but don’t pick long or float without a reason. In an exam, name the 8 primitives, then say String is a class.

Let's take this on the board with one tiny Main class — no extra files. Data Types in Java — output: 10 then 99.5 then true. int, double, boolean — three real primitives. Start from main, go line by line, and stop at each print. That output is the proof for Data Types.

Exam tip

Name the 8 primitives. Then say String is a class, not a primitive.

Example

public class Main {
  public static void main(String[] args) {
    int count = 10;
    double price = 99.5;
    boolean ok = true;
    System.out.println(count);
    System.out.println(price);
    System.out.println(ok);
  }
}

Data Types in Java — output: 10 then 99.5 then true. int, double, boolean — three real primitives.

Short notes

  • DefData type = what kind of value a box can hold.
  • Rule8 primitives: byte short int long float double char boolean.
  • RememberDaily use int and double. boolean is true/false, not 0/1.
  • TrapString is not a primitive. It is a class.

Questions

1

How many primitive types?

2

Name them.

3

Is String a primitive?

Previous← Java VariablesNextUnicode System in Java →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.