JAVA PROGRAMMING REVIEWER 2025
A Complete Study Guide for Java Programming Topics
1. JAVA OPERATORS
Operators are symbols used to perform specific operations on variables and values. They are essential for
performing calculations, comparisons, and logical decisions in Java.
Types of Java Operators:
1 Arithmetic Operators: + (addition), - (subtraction), * (multiplication), / (division), % (modulus). Used for
mathematical operations.
2 Relational Operators: == (equal to), != (not equal to), > (greater than), < (less than), >= (greater than
or equal to), <= (less than or equal to). Used for comparison between two values.
3 Logical Operators: && (AND), || (OR), ! (NOT). Used to combine multiple conditions in control
statements.
4 Assignment Operators: =, +=, -=, *=, /=, %=. Used to assign or modify variable values.
5 Increment and Decrement Operators: ++ (increase by 1), -- (decrease by 1). Used mostly in loops
and counters.
6 Conditional (Ternary) Operator: condition ? value1 : value2. Used for short if-else expressions.
Example: int sum = a + b;
2. LOOPS IN JAVA
Loops are control structures used to execute a block of code repeatedly while a certain condition is true.
1 While Loop: Executes the block as long as the condition is true.
2 Do-While Loop: Executes the block at least once, then checks the condition.
3 For Loop: Runs a block of code a specific number of times using a counter variable.
Example:
for (int i = 0; i < 5; i++) { [Link](i); }
3. ARRAYS
An array is a collection of elements of the same type stored in a single variable. Each element can be
accessed by its index number.
Example: int[] numbers = {1, 2, 3, 4, 5};
1 The index starts at 0 (first element is index 0).
2 The size of an array is fixed once declared.
3 Used to store multiple values in one variable instead of many separate ones.
4. MULTIDIMENSIONAL ARRAYS
A multidimensional array is an array that contains other arrays, often used to represent tables, grids, or
matrices.
Example: int[][] matrix = { {1, 2}, {3, 4}, {5, 6} };
1 Accessed using multiple indices, e.g., matrix[0][1].
2 Commonly used for mathematical, tabular, or image data representation.
5. SORTING ALGORITHMS
Sorting algorithms are methods used to arrange data in a particular order (ascending or descending). They
are essential for organizing, searching, and analyzing data efficiently.
Bubble Sort
Bubble Sort repeatedly compares adjacent elements and swaps them if they are in the wrong order. After
each pass, the largest value moves to its correct position at the end.
Example: for (i = 0; i < n-1; i++) for (j = 0; j < n-i-1; j++) if (arr[j] > arr[j+1]) swap(arr[j], arr[j+1]);
Advantages: Easy to understand, no extra memory, stable sort. Disadvantages: Very slow for large data
(O(n²)).
Insertion Sort
Insertion Sort builds the final sorted array one element at a time by inserting each item into its proper place
in the already sorted part of the list.
Example: int[] arr = {23, 1, 10, 5, 2};
Advantages: Simple, works well for small or nearly sorted data, stable. Disadvantages: Inefficient for large
datasets (O(n²)).
Selection Sort
Selection Sort repeatedly finds the smallest (or largest) element from the unsorted part and moves it to the
sorted section.
Example: int[] arr = {29, 10, 14, 37, 13};
Advantages: Simple, requires little memory. Disadvantages: Slow for large datasets (O(n²)).
Merge Sort
Merge Sort is a divide-and-conquer algorithm that divides the array into smaller subarrays, sorts them, and
merges them back together.
Example: Divide [38, 27, 43, 10] → sort each half → merge → [10, 27, 38, 43].
Advantages: Very efficient (O(n log n)), stable, works well for large data. Disadvantages: Uses extra
memory (O(n)).
Summary of Sorting Algorithms:
Bubble Sort – Simple but slow (O(n²))
Insertion Sort – Good for small or nearly sorted data (O(n²))
Selection Sort – Easy but not efficient for large datasets (O(n²))
Merge Sort – Efficient and stable, uses extra space (O(n log n))