Java Basics and Data Types
Harry
· 16 Sep 2026
· 13 views
Log in to track your progress and mark lessons complete.
Sponsored
Primitives and literals
Java has eight primitives: byte, short, int, long, float, double, char, boolean. Know their sizes and default values, and watch literal forms:
int hex = 0xFF; // 255
int bin = 0b1010; // 10
long big = 1_000_000L;
double d = 1.5e3; // 1500.0
Wrappers and autoboxing
Each primitive has a wrapper class (Integer, Double…). Java auto-converts between them, which the exam probes with caching gotchas:
Integer a = 127, b = 127;
System.out.println(a == b); // true (cached -128..127)
Integer c = 200, d = 200;
System.out.println(c == d); // false (new objects)
System.out.println(c.equals(d)); // true
Operators and promotion
- Integer division truncates:
7 / 2 == 3. - Mixed arithmetic promotes to the wider type:
int + doubleis adouble. &&/||short-circuit;&/|do not.
Key points
- Know the eight primitives, their sizes and defaults.
- Use
equals()not==to compare wrapper values. - Integer division truncates; arithmetic promotes to the wider type.
- Understand short-circuit vs non-short-circuit operators.