Course Overview
This course teaches Java from the ground up — starting with how the JVM works and your first program, through to OOP, Collections, and Exception Handling. Every concept is reinforced with hands-on coding. By the end you will be fluent in core Java and fully prepared for technical interviews in software development and QA automation roles.
Introduction to Java & Setup
JDKvsJREvsJVM— what each component does and why all three matter- How Java achieves platform independence — write once, run anywhere via bytecode
- Installing JDK and setting up Eclipse IDE for Java development
- Configuring
JAVA_HOMEand verifying withjava -version
- Structure of a Java class —
classkeyword,public static void main(String[] args) System.out.println()andSystem.out.print()— printing output to the console- Compiling with
javacand running withjavafrom the command line - Organising classes into
packages — naming conventions and folder structure
Data Types & Variables
- Variable declaration and assignment — naming rules and conventions
- Integer types:
byte,short,int,long— size and valid range of each - Floating-point types:
floatvsdouble— precision and when to use each char— single Unicode character, stored as a 16-bit numberboolean—true/falseonly; used in all conditions and loopsString— non-primitive reference type; immutable character sequence
finalkeyword — declaring a constant that cannot be reassigned- Widening (implicit) conversion — Java automatically promotes smaller types to larger
- Narrowing (explicit) casting —
(int) 3.14— data loss risk and when it is acceptable
Operators
- Arithmetic:
+,-,*,/,%(modulus) — integer division behaviour - Increment / Decrement:
++,--— prefix vs postfix difference - Relational:
==,!=,>,<,>=,<=— always returnboolean - Logical:
&&(AND),||(OR),!(NOT) — short-circuit evaluation - Assignment shortcuts:
+=,-=,*=,/=,%= - Ternary operator:
condition ? valueIfTrue : valueIfFalse
Control Flow — Conditional Statements
if,else,else ifladder — single and multi-branch decision making- Nested
if— conditions inside conditions for complex logic switchstatement —case,default, andbreak; fall-through behaviourScannerclass —nextInt(),nextLine(),nextDouble()for reading user input
Loops & Pattern Printing
forloop — initialisation, condition, update; most common for counted iterationswhileloop — condition checked before each iteration; runs zero or more timesdo-whileloop — condition checked after; always executes at least oncebreak— immediately exits the current loopcontinue— skips the rest of the current iteration and moves to the next- Nested loops — outer loop controls rows, inner loop controls columns
- Star (
*) patterns — right triangle, left triangle, pyramid, diamond - Number patterns — sequential, mirrored, and Pascal's triangle style
- Analysing patterns — how to break any design into row count and column logic
Arrays — 1D & 2D
- Array declaration:
int[] arr = new int[5]— fixed size, zero-indexed - Initialisation at declaration:
int[] arr = {10, 20, 30} arr.length— getting the size of an array- Iterating with
forloop and enhancedfor-eachloop - Common operations: finding max/min, sum, average, reverse, search
Arrays.sort()— sorting in ascending order
- Declaration:
int[][] matrix = new int[rows][cols]— row-major storage - Nested loops to traverse rows and columns of a 2D array
- Matrix operations — addition, transpose, diagonal sum
Methods
- Method signature: access modifier, return type, method name, parameter list
- Calling a method — passing arguments, receiving return values
voidmethods vs methods with areturntypestaticmethods — called on the class directly without creating an object- Instance (non-static) methods — require an object to call
- Method overloading — same name, different parameter types or count
- Writing generic, reusable utility methods for common operations
OOP — Classes, Objects & Constructors
- Class as a blueprint — instance variables (fields) and instance methods
- Creating objects:
ClassName obj = new ClassName() - Default constructor — auto-provided by Java when no constructor is defined
- Parameterised constructor — initialising objects with values at creation time
thiskeyword — resolving naming conflicts between parameters and instance fields
static & final Membersstaticvariable — one copy shared across all instances of a classstaticmethod — belongs to the class, not to any objectfinalvariable — constant; must be assigned exactly oncefinalmethod — cannot be overridden by a subclassfinalclass — cannot be extended (e.g.Stringis a final class)
OOP — Inheritance & Encapsulation
extendskeyword — child class inherits all non-private members of the parentsuperkeyword — calling the parent class constructor or methods- Types: single inheritance, multilevel inheritance, hierarchical inheritance
- Java does not support multiple class inheritance — why, and how interfaces solve this
private,protected,public, package-private — scope of each- Encapsulation pattern —
privatefields withpublicgetter and setter methods - Why encapsulation prevents invalid state and makes code easier to maintain
- Method overloading — same method name, different parameter signature
OOP — Polymorphism & Type Casting
- Method overriding — child class provides its own implementation of a parent method
@Overrideannotation — compile-time check that overriding is valid- Runtime (dynamic) polymorphism — method resolved at runtime based on actual object type
- Overloading vs overriding — compile-time vs runtime; key differences interviewers test
- Upcasting — implicit;
Animal a = new Dog()— always safe - Downcasting — explicit;
Dog d = (Dog) a— requiresinstanceofcheck instanceofoperator — safely checking type before casting
Interfaces & Abstract Classes
interfacekeyword — defines a contract of method signatures without implementationimplementskeyword — a class agrees to provide all interface methods- Interface methods are implicitly
public abstract; fields arepublic static final - A class can
implementmultiple interfaces — Java's answer to multiple inheritance
abstract class— cannot be instantiated; must be subclassedabstractmethod — declared without a body; subclass must provide implementation- Can contain both
abstractmethods and fully implemented (concrete) methods - Interface vs abstract class — when to use each; key differences for interviews
String Handling
Stringis immutable — every operation creates a new object in the String Poollength(),charAt(int),indexOf(String),lastIndexOf()substring(int start),substring(int start, int end)toUpperCase(),toLowerCase(),trim()replace(),contains(),startsWith(),endsWith()equals()vsequalsIgnoreCase()vs==— why==compares references, not contentsplit(String regex),join(),toCharArray()
StringBuilder— mutable, not thread-safe, faster for single-threaded useappend(),insert(),delete(),reverse(),toString()StringBuffer— mutable, thread-safe, used in multi-threaded programsStringvsStringBuildervsStringBuffer— performance and thread-safety trade-offs
Collections Framework
ArrayList— dynamic array; fast random access; allows duplicates; maintains insertion orderLinkedList— doubly-linked list; fastadd/removeat ends; slower random access- Common methods:
add(),get(int),remove(),size(),contains(),set() - Iterating with
for-eachandIterator
HashSet— no duplicates, no guaranteed order; backed by a hash tableLinkedHashSet— no duplicates, preserves insertion orderTreeSet— no duplicates, elements stored in natural sorted order
Queueinterface — FIFO;offer(),poll(),peek()Stack— LIFO;push(),pop(),peek()Vector— legacy thread-safe version ofArrayList
HashMap— key-value pairs, no guaranteed order, allows onenullkeyLinkedHashMap— key-value pairs, preserves insertion order- Common methods:
put(),get(),remove(),containsKey(),keySet(),values()
Comparableinterface —compareTo()for natural ordering inside the classComparatorinterface —compare()for custom ordering defined outside the classCollections.sort(list)andCollections.sort(list, comparator)Iterator—hasNext()andnext()for safe manual traversal
Exception Handling
- What is an exception — an unexpected event that disrupts normal program execution
- Checked vs unchecked exceptions — compile-time vs runtime
tryblock — code that may throw an exceptioncatch(ExceptionType e)— handling a specific exception type- Multiple
catchblocks — handling different exception types separately finallyblock — always executes; used for resource cleanup (closing files, connections)throwkeyword — manually throwing an exception from your codethrowskeyword — declaring that a method may throw a checked exception- Common exceptions:
NullPointerException,ArrayIndexOutOfBoundsException,NumberFormatException,ArithmeticException
Interview Preparation
OOP Pillars — Be ready to explain all four: Inheritance, Polymorphism, Encapsulation, Abstraction — with examples and real code. Overloading vs overriding is always asked.
Collections Comparison — Know ArrayList vs LinkedList, HashMap vs LinkedHashMap, HashSet vs TreeSet, and when to use Comparable vs Comparator.
String Questions — Why is String immutable? What is the String Pool? When to use StringBuilder? How does equals() differ from ==? These are asked in virtually every interview.
Interface vs Abstract Class — One of the most common Java questions. Know the differences clearly: multiple implementation, constructors, default methods, and when each design choice makes sense.
Exception Handling — Always demonstrate correct try-catch-finally usage. Know the difference between checked and unchecked exceptions and when to use throw vs throws.
Coding Rounds — Practice array problems, string manipulation, pattern printing, and number challenges on LeetCode or HackerRank. Write clean, well-named code — interviewers notice.