Guide
Syntax, OOP, collections, exceptions, streams and JVM basics - with
exam-focused examples
Complete Study Guide | Key Concepts | Examples | Practice Questions
, 1. Java Basics and the JVM
Java is statically typed, object-oriented and platform-independent: source compiles to bytecode, and the JVM
executes it anywhere. The JDK includes compiler + JVM; the JRE is runtime only.
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
int x = 5;
double pi = 3.14;
String s = "Java";
boolean ok = true;
}
}
- Compile: javac Hello.java -> run: java Hello.
- Primitive types: byte, short, int, long, float, double, char, boolean.
- String is a class (immutable); compare with .equals(), never ==.
- JVM does garbage collection - no manual memory management like C++.
Page 1