Java Syntax Basics
Fast recall
Quick revision
Core answer
Whether you can list the eight primitive types with their sizes and default values, and explain the difference between primitive and reference types.
Confusing the size of char (16-bit, not 8-bit) or thinking boolean has a defined size in the spec, or forgetting that primitives are passed by value.
Explain autoboxing and unboxing, the wrapper class cache for Integer (-128 to 127), and why Java chose fixed-size primitives for cross-platform consistency.
Interview-ready guide
Interview answer
Java is statically typed, so each variable and expression has a known type and the compiler checks assignments and method calls against it. The language has eight primitive types and reference types such as classes, interfaces, and arrays.
This catches many errors before execution, but not every type-related problem: a downcast may fail at runtime and arrays perform runtime store checks. Java always passes argument values. For an object, that value is a reference, which lets two variables refer to the same object without making Java pass-by-reference.
Java Syntax Basics
Direct Answer
Java's type system assigns a type to every variable and expression and checks which operations are legal. Java has primitive types and reference types. It is statically typed, so many mistakes are rejected during compilation, while runtime checks still apply to operations such as casts and array stores. Java always passes argument values; an object argument value is a reference.
Common Mistakes & Pitfalls
Confusing the size of char (16-bit, not 8-bit) or thinking boolean has a defined size in the spec, or forgetting that primitives are passed by value.
Check your understanding
Answer these without looking back at the article.
- What is the difference between autoboxing and unboxing in Java?
- Why does Integer cache values between -128 and 127?
- What is the size of a char in Java and why is it 16-bit?
- How does Java handle type promotion in arithmetic expressions?
- What is the default value of a boolean primitive vs a Boolean reference?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.