The six core lessons give you a strong start. Exams also test exact language rules, tracing output, short programs, and explanations of why code behaves a certain way. Use this extension as a revision sheet; examples use standard Java syntax and can be adapted to your syllabus.
1. Operators and expression tracing
Know arithmetic (+ - * / %), comparisons, logical operators, assignment operators and increment/decrement. Integer division discards the fractional part; operator precedence determines grouping.
int a = 7 / 2; // 3
int b = 7 % 2; // 1
int x = 4;
int y = x++ + ++x; // 4 + 6 = 10; x is 6
Exam habit: trace each statement in order. Parentheses make intent clearer; avoid complicated expressions with multiple side effects in production code.
2. Strings
String objects are immutable: a method such as toUpperCase() returns a string; it does not change the original object. Use equals for text equality, not ==.
String a = "java";
String b = a.toUpperCase();
System.out.println(a); // java
System.out.println(b); // JAVA
System.out.println("java".equals(a)); // trueLearn length(), charAt(), substring(), contains(), indexOf(), split(), trim()/strip(), and StringBuilder for repeated modifications.
3. Scope, defaults and casting
Local variables must be assigned before use. Instance fields receive default values (numeric zero, false, or null for references). Narrowing conversions can lose information.
double price = 9.8;
int whole = (int) price; // 9
int n = 5;
double d = n; // 5.0, widening
Distinguish local variables, parameters, instance fields and static class fields. A variable declared inside a block is not accessible outside that block.
4. Constructors and access
A constructor initializes an object and has the same name as its class, with no return type. If you declare no constructor, Java supplies a no-argument default constructor; once you declare one, that automatic constructor is not supplied.
class Student {
private String name;
Student(String name) {
this.name = name;
}
String getName() { return name; }
}private restricts access to the class; package-private has no modifier; protected and public have broader access rules. Prefer private fields and controlled methods.
5. Packages, imports and static
A package organizes related types and helps define access boundaries. The package declaration, when present, comes before imports. import lets you refer to a type by its simple name. static members belong to the class rather than an individual object.
import java.util.Scanner;
class Counter {
static int total = 0;
Counter() { total++; }
}final on a variable means it can be assigned only once; on a method it prevents overriding; on a class it prevents subclassing.
6. Recursion and algorithm basics
Recursion is a method calling itself. Every recursive solution needs a base case and progress toward that case. A loop is often simpler for basic repetition.
static int factorial(int n) {
if (n < 0) throw new IllegalArgumentException();
if (n <= 1) return 1; // base case
return n * factorial(n - 1);
}Common complexity vocabulary: O(1) constant, O(n) linear, O(n²) quadratic. A loop inside a loop over the same input is often quadratic.