A quick reference guide for coding interviews.
🔹 1. Basics
Data Types
- Primitives →
byte, short, int, long, float, double, char, boolean
- Non-primitive →
String, Arrays, Objects
Syntax
class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Input/Output
import java.util.Scanner;
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
System.out.println(x);
🔹 2. Control Structures
- If-Else, Switch
- Loops →
for, while, do-while, enhanced-for
for (int x : arr) {
System.out.println(x);
}
🔹 3. Methods
int add(int a, int b) {
return a + b;
}
- Overloading → same name, diff params