This review sheet covers key Grade 12 ICS4U concepts in an exam■friendly format.
1. Object-Oriented Programming (OOP)
1 Class: A blueprint that defines fields (variables) and methods (behaviour).
2 Object: An instance of a class created using the 'new' keyword.
3 Encapsulation: Keeping data private using access modifiers and providing getters/setters.
4 Constructor: Special method that initializes objects. Must have the same name as the class.
5 Constructor chaining: Calling one constructor from another using this().
6 toString(): Returns a String representation of the object.
7 equals(): Compares objects based on their data, not memory location.
2. Arrays and ArrayLists
1 Arrays have a fixed size and store elements of the same data type.
2 ArrayList size can change dynamically.
3 Arrays use index notation: arr[i].
4 ArrayLists use methods: add(), get(), set(), remove().
5 Arrays of objects store references to objects, not the objects themselves.
3. File Input (Reading from Files)
1 File f = new File("filename.txt"); creates a file object.
2 Scanner s = new Scanner(f); reads from a file.
3 nextLine() reads a full line as a String.
4 Integers must be converted using Integer.parseInt().
5 FileNotFoundException must be handled using try-catch.
4. Sorting Algorithms
1 Selection Sort: Finds the smallest value and swaps it into place. Time complexity: O(n²).
2 Bubble Sort: Swaps adjacent elements repeatedly. Time complexity: O(n²).
3 Insertion Sort: Inserts elements into a sorted portion of the list. Time complexity: O(n²).
4 Merge Sort: Recursively divides and merges lists. Time complexity: O(n log n).
5 Quick Sort: Uses a pivot to partition the array. Average time: O(n log n).
6 Heap Sort: Uses a heap data structure. Time complexity: O(n log n).