Basics for Javas
Java basics are the building blocks every program uses: primitive and reference types, operators, conditionals, loops, methods, and the class and object model. This is the first unit of the Language stage, and everything later in Java, from collections to the JVM, rests on these ideas.
Stage: Language · Part of the Java roadmap · Last reviewed 19 November 2026
What to learn in Basics
- Declare variables with the right primitive type and explain why int and long differ
- Write if, switch and loop constructs to control program flow
- Define a class with fields, a constructor and methods, then create objects from it
- Explain the difference between a primitive and a reference variable
- Compile and run a program with javac and java from the command line
Basics interview questions
What is the difference between == and equals() on Strings in Java?
The == operator compares references, so it checks whether two variables point to the same object. The equals() method compares content. Two Strings with the same characters can be different objects, so equals() is the correct way to compare them.
Why is Java called platform independent?
The compiler turns source code into bytecode, not machine code. Any machine with a compatible JVM can run that bytecode, and the JVM translates it for the local operating system and CPU. So the same .class files run on Windows, Linux and macOS.
Where Basics fits in the Java roadmap
Basics belongs to the Language stage (beginner level), which takes about 32 hours. Syntax and OOP.