Notes / Java / Data Types

Data Types in Java — Revision Notes

A quick-reference cheat sheet: definition, syntax, example, common mistakes and an interview tip.

beginner 📖 2 min revision

Definition

📌 Data Types Java defines exactly 8 primitive types with fixed sizes that never change across platforms — this consistency is part of what makes Java code portable..

Syntax

syntax
int wholeNumber;
double decimalNumber;
char singleCharacter;
boolean trueOrFalse;

Example

java
public class Main {
    public static void main(String[] args) {
        int age = 20;
        double gpa = 8.9;
        char grade = 'A';
        boolean passed = true;
        System.out.println(age + " " + gpa + " " + grade + " " + passed);
    }
}

Output

output20 8.9 A true

Important Points

Common Mistakes

Interview Tip

🎯 Before your interview Interviewers often ask you to list Java's 8 primitive types from memory — it's worth memorizing them.
Back to notes Read full lesson →