Skip to content
Study Hall
← ICS3U Computer Science

ICS3U · Exam review

Computer Science Exam Review

A practice exam with questions from all 7 units, then the key facts from every lesson, unit by unit. For a deeper look at one unit, open its test review.

Unit test reviews

  1. Unit 1. Intro to Computers~10%
  2. Unit 2. Programming Basics~15%
  3. Unit 3. If Statements~15%
  4. Unit 4. Looping~15%
  5. Unit 5. Methods~15%
  6. Unit 6. Arrays~10%
  7. Unit 7. Software Development & the CPT~20%

Practice exam

35 questions, the same number from each unit. Each one shows the lesson it comes from.

  1. Unit 1: Components, Specifications and Building to a Need
    1
    A user edits 4K video and complains the timeline stutters whenever effects are added. Which upgrade addresses the most likely bottleneck?
  2. Unit 1: Components, Specifications and Building to a Need
    2
    Why is electrostatic discharge damage especially frustrating to diagnose?
  3. Unit 1: How Computers Represent Data
    3
    The ASCII code for 'M' is 77. What is the ASCII code for 'm'?
  4. Unit 1: Files, Folders and a Workspace That Works
    4
    Put these file names in the order a computer would sort them alphabetically.
    1. 1lab3.java
    2. 2lab20.java
    3. 3lab2.java
    4. 4lab1.java
    5. 5lab10.java
  5. Unit 1: Files, Folders and a Workspace That Works
    5
    Which statement about compression is correct?
  6. Unit 2: Your First Java Program
    6
    Which of these is the correct signature for the method where a Java program starts?
  7. Unit 2: Your First Java Program
    7
    What file does javac Hello.java produce?
  8. Unit 2: Variables, Primitive Types and Casting
    8
    What does System.out.println(5 / 2.0); print?
  9. Unit 2: Operators, Expressions and Input
    9
    What does 10 % 4 * 2 evaluate to?
  10. Unit 2: Operators, Expressions and Input
    10
    Order these steps as Java evaluates 2 + 3 * 4 - 6 / 2.
    1. 1Evaluate 6 / 2, giving 3
    2. 2Subtract 3 from 14, giving 11
    3. 3Add 2 + 12, giving 14
    4. 4Evaluate 3 * 4, giving 12
  11. Unit 3: Boolean Expressions and Comparison
    11
    Which line correctly tests whether the String answer holds the text yes?
  12. Unit 3: Boolean Expressions and Comparison
    12
    Given String a = "cat"; and String c = new String("cat");, what does a == c produce?
  13. Unit 3: if, else if and else
    13
    What is wrong with if (total > 100); followed by a block that prints a discount?
  14. Unit 3: switch, Validation and Choosing a Structure
    14
    In a switch with cases 1, 2, 3 and default, all printing their own word and none having a break, what is printed when the selector is 3?
  15. Unit 3: switch, Validation and Choosing a Structure
    15
    Why should a validation message say what would be acceptable, not just that something is wrong?
  16. Unit 4: while and do-while
    16
    A loop prints the same value forever. Which part is most likely missing?
  17. Unit 4: while and do-while
    17
    Put the parts of a correct sentinel-controlled input loop in order.
    1. 1Prompt and read the next value at the end of the body
    2. 2Update the accumulator with the current value
    3. 3Report the result after the loop finishes
    4. 4Initialize the accumulator before the loop
    5. 5Prompt and read the first value (the priming read)
    6. 6Test the value against the sentinel in the loop condition
  18. Unit 4: for Loops and Counting
    18
    Why can an enhanced for loop for (int mark : marks) never throw an ArrayIndexOutOfBoundsException?
  19. Unit 4: Accumulators, Counters and Nested Loops
    19
    What is the final value of product? int product = 1; for (int i = 1; i <= 5; i++) { product = product * i; }
  20. Unit 4: Accumulators, Counters and Nested Loops
    20
    A nested loop prints every item on its own line instead of in rows. What is wrong?
  21. Unit 5: Writing and Calling Methods
    21
    What does a return type of void tell you about a method?
  22. Unit 5: Writing and Calling Methods
    22
    Given public static int triple(int n) { return n * 3; }, what is printed by System.out.println(triple(4) + triple(2));?
  23. Unit 5: Parameters, Arguments and Scope
    23
    What is printed? int total = 0; for (int i = 1; i <= 3; i++) { int d = i * 2; total += d; } System.out.println(total);
  24. Unit 5: Decomposition and Program Design
    24
    Order the steps of top-down design.
    1. 1Write stubs so the program compiles and runs
    2. 2Name each piece with a verb and write its signature
    3. 3Replace one stub at a time, testing after each
    4. 4State the whole job in one sentence
    5. 5Split it into a handful of major steps
    6. 6Split any step that is still too big to write directly
  25. Unit 5: Decomposition and Program Design
    25
    Which principle says that the same logic should not be written out in several places?
  26. Unit 6: Declaring and Using Arrays
    26
    For int[] a = {5, 10, 15, 20};, what is the value of a[1]?
  27. Unit 6: Traversing Arrays and the Standard Algorithms
    27
    By convention, what value does a linear search return when the target is not in the array?
  28. Unit 6: Sorting and Binary Search
    28
    binarySearch(d, 21) runs on {3, 8, 12, 17, 21, 26, 30, 34, 41, 45, 52, 58, 63, 70, 77}. Put the elements it checks in the order it checks them.
    1. 1d[3] = 17
    2. 2d[4] = 21
    3. 3d[5] = 26
    4. 4d[7] = 34
  29. Unit 6: Strings as Sequences of Characters
    29
    Put these Strings in the order compareTo sorts them, smallest first.
    1. 1"apple"
    2. 2"banana"
    3. 3"apples"
    4. 4"Zebra"
  30. Unit 6: Two-Dimensional Arrays
    30
    What does String[][] board = new String[3][3]; contain immediately after creation?
  31. Unit 7: The Software Development Life Cycle
    31
    Order the stages of the software development life cycle.
    1. 1Maintenance
    2. 2Testing
    3. 3Implementation
    4. 4Analysis and requirements
    5. 5Design
  32. Unit 7: Problem-Solving, Pseudocode and Algorithm Design
    32
    A program must calculate a subtotal, apply a discount and then add 13 percent HST. In which order must the steps run?
  33. Unit 7: Code Style, Conventions and Maintainable Code
    33
    Using CheckoutTotal (discount 10 percent at 35 dollars or more, then 13 percent HST), what total is printed for a cart whose prices add up to 30.00 dollars? Give the answer to 2 decimal places.
    dollars
  34. Unit 7: Computing and Environmental Stewardship
    34
    A 350 W gaming PC runs 3 hours a day for 365 days. How many kilowatt-hours does it use? Round to 2 decimal places.
    kWh
  35. Unit 7: Emerging Research and Careers in Computing
    35
    Which portfolio is strongest for a computing application?

Key facts by unit

Unit 1: Intro to Computers

Components, Specifications and Building to a Need

  • Bottleneck rule: for any one workload, the slowest component involved sets the performance — spend there first.
  • Compatibility gates, in order: CPU socket matches the motherboard, RAM generation matches the board, PSU wattage covers the load, case clears the GPU and cooler.
  • PSU sizing: add the CPU and GPU draw, add about 75 W for everything else, then multiply by roughly 1.3 for headroom.
  • SATA III caps at 6 Gb/s, about 550 MB/s of real data; NVMe uses PCIe lanes directly and reaches several GB/s.
  • Dual channel doubles memory bandwidth, so two matched sticks beat one stick of the same total capacity.
  • Electrostatic discharge can damage a component invisibly today and cause a failure weeks later — ground yourself before touching anything.

How Computers Represent Data

  • Binary place values from the right: — doubling each time.
  • An -bit pattern has possible values: unsigned they run to , signed they run to .
  • 8 bits = 1 byte, and 4 bits = exactly 1 hex digit because .
  • Java int is 32 bits signed, so its range is to ; exceeding it wraps around silently.
  • 1 KiB = 1024 bytes but 1 kB = 1000 bytes; lowercase b is bits, uppercase B is bytes.
  • ASCII: A is 65, a is 97 (always 32 apart), and the character 0 is 48.

Files, Folders and a Workspace That Works

  • An absolute path starts at the root and always means the same file; a relative path starts at the current working directory and survives moving the project.
  • In a relative path, . is the current folder and .. is the parent folder.
  • A file's real type is determined by its content (its signature bytes), not by its extension — renaming converts nothing.
  • Name files so they sort: ISO dates (YYYY-MM-DD), zero-padded numbers, no spaces.
  • 3-2-1 backup: three copies, on two kinds of media, with one offsite.
  • Lossless compression restores the original exactly; lossy compression discards detail permanently.
Unit 2: Programming Basics

Your First Java Program

  • Every Java program lives in a class, and execution starts at public static void main(String[] args).
  • The file name must exactly match the public class name, including capitals: public class Hello goes in Hello.java.
  • Braces { } group statements into blocks; a semicolon ; ends one statement. Braces take no semicolon.
  • javac Hello.java compiles to Hello.class; java Hello runs it — no file extension on the run command.
  • println prints then moves to a new line; print prints and leaves the cursor in place.
  • Three error types: syntax (caught at compile time), runtime (crashes mid-run), logic (runs fine, answer is wrong).

Variables, Primitive Types and Casting

  • The eight primitives are byte, short, int, long, float, double, char, boolean. String is a class, not a primitive.
  • int holds up to ; going past it wraps silently to the most negative int.
  • If both operands of / are integers, Java truncates: 5 / 2 is 2. Make one side a double to get 2.5.
  • % gives the remainder: 17 % 5 is 2, and n % 2 == 0 tests for even.
  • Widening (byte → short → int → long → float → double) is automatic; narrowing needs a cast such as (int).
  • A cast truncates toward zero — (int) 9.99 is 9 — and final constants are written in UPPER_SNAKE_CASE.

Operators, Expressions and Input

  • Precedence: brackets, then unary, then * / % left to right, then + - left to right, then assignment.
  • % sits at the same level as * and /, so 10 % 4 * 2 is (10 % 4) * 2 = 4.
  • If either operand of + is a String, + joins: "total: " + 1 + 2 gives total: 12, so bracket the arithmetic.
  • x += 3 means x = x + 3; x++ uses the old value then increments, ++x increments then uses the new one.
  • Math.round returns a long; to round to two decimals use Math.round(v * 100) / 100.0 with a double divisor.
  • After nextInt() or nextDouble(), call a bare nextLine() before reading a line of text.
Unit 3: If Statements

Boolean Expressions and Comparison

  • A boolean is only true or false; Java will not accept a number or a String where a condition is required.
  • The six relational operators are ==, !=, <, >, <=, >=, and each produces a boolean.
  • && needs both sides true, || needs at least one, ! flips. Precedence runs !, then &&, then ||.
  • Short-circuit: && skips its right side when the left is false, so a guard such as count != 0 && must come first.
  • De Morgan: and .
  • = assigns and == compares; for Strings use .equals(), because == compares references.

if, else if and else

  • An if runs its block only when the condition is true; the optional else block runs in every other case.
  • Without braces, an if controls only the very next statement — always write the braces anyway.
  • An else if chain stops at the first true condition, so overlapping ranges must go from most demanding to least.
  • Exactly one branch of an if / else if / else chain ever runs, and the rest are skipped without being tested.
  • An else binds to the nearest unmatched if, regardless of indentation.
  • The ternary condition ? valueIfTrue : valueIfFalse is an expression that produces one of two values.

switch, Validation and Choosing a Structure

  • switch compares one selector against fixed case constants; default handles everything unmatched.
  • break exits the switch. Without it, execution falls through into the statements of the cases below.
  • Stacked bare labels such as case 4: case 6: are deliberate fall-through and share one block.
  • A switch selector may be int, short, byte, char, String or an enum — never double, float, long or boolean.
  • Use switch for a list of fixed values and else if for ranges, decimals or multi-variable conditions.
  • Integer division by zero throws ArithmeticException; double division by zero gives Infinity or NaN silently.
Unit 4: Looping

while and do-while

  • Every loop needs three parts: initialize before, a condition to test, and an update inside the body.
  • A while loop tests first, so its body can run zero times.
  • A do-while loop tests last, so its body always runs at least once, and its condition is followed by a semicolon.
  • An infinite loop means the condition never becomes false — the update is almost always missing or wrong.
  • A sentinel loop needs a priming read before the loop and another read at the end of the body.
  • count++ is shorthand for count = count + 1, and total += value is shorthand for total = total + value.

for Loops and Counting

  • for (init; condition; update) — the initialization runs once, then the cycle is test, body, update, test.
  • for (int i = 0; i < n; i++) runs exactly times, with taking the values to .
  • Counting by 1 from to inclusive runs times.
  • A variable declared in the for header exists only inside the loop — using it afterwards will not compile.
  • Use for when the number of passes is known in advance, while when it is not.
  • The enhanced for loop for (int x : arr) gives you each value but no index.

Accumulators, Counters and Nested Loops

  • Declare and initialize an accumulator before the loop; change it inside. Declaring it inside resets it every pass.
  • A sum starts at 0, a product starts at 1, and a counter starts at 0.
  • A max or min tracker starts at the first element, and its loop then starts at index 1.
  • When both bounds are fixed, total inner passes = outer passes inner passes.
  • When the inner bound depends on the outer counter, add the pass counts instead of multiplying.
  • break exits the loop immediately; continue skips to the next pass. Both affect only the innermost loop containing them.
Unit 5: Methods

Writing and Calling Methods

  • A signature is: access modifier, static, return type, name, then the parameter list in brackets.
  • void means the method hands nothing back; any other return type demands a return on every path.
  • return supplies the value and ends the method immediately — nothing after it runs.
  • A call pauses the current line, runs the method, and resumes at exactly the same point with the returned value.
  • Method names are camelCase verbs starting with a lowercase letter: calculateAverage, not CalculateAverage or avg.
  • Methods are written inside the class but outside every other method; they can never be nested.

Parameters, Arguments and Scope

  • A parameter is in the definition and has a type; an argument is at the call and is a value.
  • Java matches arguments to parameters by position — number, order and type must all agree.
  • Java is pass by value: a primitive argument is copied, so reassigning the parameter never changes the caller's variable.
  • To make a change stick, return the new value and assign it: score = addTen(score);
  • A variable exists from its declaration to the closing brace of its block, and nowhere else.
  • Overloading means same name, different parameter list. A different return type alone is not enough.

Decomposition and Program Design

  • One method, one job — if you need the word "and" to describe it, split it.
  • Method names are verbs or verb phrases in camelCase; boolean methods start with is or has.
  • Top-down design: split the job into steps, then split any step that is still too big, before writing any logic.
  • A stub has the correct signature and a placeholder body so the program compiles and runs while it is unfinished.
  • Test one method at a time as you replace each stub, so any new bug is in the piece you just wrote.
  • Every method called directly from main must be static, because main runs without an object.
Unit 6: Arrays

Declaring and Using Arrays

  • int[] a = new int[n]; creates n slots filled with the default value; int[] a = {1, 2, 3}; creates and fills in one step.
  • Indexes start at 0, so the valid range is 0 to and the last element is a[a.length - 1].
  • Arrays use .length with no brackets; Strings use .length() with brackets.
  • Defaults: 0 for whole numbers, 0.0 for decimals, false for boolean, null for String and other objects.
  • An array's length is fixed at creation and can never change.
  • Any index below 0 or at least equal to the length throws ArrayIndexOutOfBoundsException.

Traversing Arrays and the Standard Algorithms

  • The standard traversal is for (int i = 0; i < arr.length; i++) — strict less-than, never <=.
  • Use for-each when you need only the values; use the index loop when you must modify elements or report a position.
  • Assigning to a for-each loop variable changes a copy and leaves the array unchanged.
  • Initialize a max or min search with arr[0], never with 0, then loop from index 1.
  • A linear search returns the index on a match and −1 after the loop if nothing matched.
  • Swapping needs a temporary variable, and reversing swaps from both ends inwards for length / 2 passes.

Sorting and Binary Search

  • Selection sort: each pass finds the smallest unsorted value and swaps it into the next slot; n elements need n − 1 passes and n(n − 1)/2 comparisons.
  • Bubble sort: each pass swaps out-of-order neighbours, carrying the largest remaining value to the end; a pass with no swaps means the array is sorted.
  • Swapping two elements always needs a temporary variable: save, copy over, restore.
  • Java passes arguments by value, but an array variable's value is a reference, so a method can change the caller's elements — not which array the caller's variable points to.
  • Binary search requires sorted data; it checks the middle, then discards half the range, using low = mid + 1 or high = mid - 1.
  • Worst-case binary search on n elements needs floor(log₂ n) + 1 checks — 20 for a million elements, against a million for linear search.

Strings as Sequences of Characters

  • String characters are indexed from 0 to s.length() - 1; length() is a method with brackets, unlike an array's length field.
  • s.charAt(i) returns a char; s.substring(a, b) returns the characters from index a up to but not including b, so its length is b − a.
  • s.indexOf(x) returns the index of the first occurrence of x, or −1 if it is absent.
  • Strings are immutable: toUpperCase, toLowerCase and substring return new Strings, so store the result.
  • Use equals or equalsIgnoreCase for matching text, and compareTo for order: negative means first, 0 means equal, positive means after.
  • A position outside 0 to length − 1 throws StringIndexOutOfBoundsException.

Two-Dimensional Arrays

  • int[][] grid = new int[3][4]; makes 3 rows of 4 columns — 12 cells, all starting at 0.
  • A cell is grid[row][col]: row first, column second, both counting from 0.
  • grid.length is the number of rows; grid[0].length is the number of columns.
  • Nested loops traverse a grid — outer loop over rows, inner loop over columns.
  • The inner body runs rows times columns times in total, so a 3 by 4 grid means 12 passes.
  • Java stores grids in row-major order: all of row 0, then all of row 1, and so on.
Unit 7: Software Development & the CPT

The Software Development Life Cycle

  • The stages are analysis, design, implementation, testing and maintenance — in that order, and maintenance loops back to analysis.
  • A requirement must be checkable: if you cannot name a test for it, rewrite it.
  • Functional requirements say what the program does; non-functional say how well it must do it.
  • Waterfall completes each stage once; iterative repeats all the stages on small slices to get feedback early.
  • A defect found after release costs roughly 30 times what it costs at the analysis stage.
  • Maintenance consumes the majority of a successful program's total effort.

Problem-Solving, Pseudocode and Algorithm Design

  • Decomposition splits a problem into independent sub-problems; pattern recognition spots the ones you have already solved.
  • Abstraction means deliberately ignoring detail that does not affect the solution.
  • An IPO chart lists inputs, processing and outputs, and exposes values that were never actually supplied.
  • Pseudocode is structured English with no syntax rules; it exists so the logic can be checked cheaply.
  • In a flowchart, a diamond is a decision and must have exactly two exits, both of which lead somewhere.
  • Boundary words in a specification — inclusive, at least, up to — decide between < and <=.

Testing, Debugging and Documentation

  • Every test set needs normal, boundary and invalid cases; boundary cases find the most bugs.
  • Test the boundary value, one below it and one above it — that is where < and <= disagree.
  • Syntax errors stop compilation, runtime errors stop execution, logic errors produce a wrong answer in silence.
  • A stack trace gives the exception type, the message, and the exact file and line where it stopped.
  • A trace table finds logic errors by executing the code by hand exactly as written.
  • Comments should explain why, not what; the code already says what.

Code Style, Conventions and Maintainable Code

  • Classes use UpperCamelCase, methods and variables use lowerCamelCase, and constants use UPPER_SNAKE_CASE.
  • Indent one level (usually four spaces) per block so the layout on screen matches the logic.
  • Replace magic numbers with final named constants, declared once, so a change of value is a one-line edit.
  • Comments explain WHY; every file gets a header comment and every method a Javadoc comment (/** ... */ with @param and @return).
  • Refactoring changes structure without changing behaviour: one small change at a time, re-testing after each.
  • Commit small, working versions with messages that say what changed and why, and use branches for risky changes.

The Culminating Project, Society and Careers

  • Scope a project by sorting features into must, should, could and will-not have, and build strictly in that order.
  • A milestone must be provable by running something, not by an estimate of how complete it feels.
  • Reserve about a fifth of your time for testing, fixing and documentation.
  • Manufacturing a device usually costs more energy than the electricity it will consume in its whole life, so extending lifespan is the strongest environmental lever.
  • E-waste contains both hazardous materials and recoverable metals, so it must go to a designated recycling program.
  • Ontario pathways include university computer science or engineering, college programming and IT, combined transfer routes, and certification.

Computing and Environmental Stewardship

  • Energy in kWh = power in watts ÷ 1000 × hours of use; cost = kWh × the rate per kWh (about 0.12 dollars in Ontario, approximately).
  • For laptops and phones, manufacturing is usually the largest part of the lifetime footprint, so keeping devices longer is the strongest lever.
  • Power-management policies (display off, sleep, overnight shutdown) save the most for the least effort, because most computers are idle most of the time.
  • ENERGY STAR certifies energy efficiency; EPEAT rates the whole life cycle in Bronze, Silver and Gold tiers.
  • In Ontario, producers are responsible for collecting and recycling electronics; use municipal depots, retailer take-back or producer drop-off programs.
  • Deleting or formatting does not erase data: wipe, secure-erase or crypto-erase storage, or destroy it, before disposal.

Emerging Research and Careers in Computing

  • Machine learning trains a model on labelled examples and must be tested on data it has never seen; biased or unrepresentative data produces biased results.
  • A register of n qubits is described by 2ⁿ numbers, but quantum computers help only with certain problems; post-quantum encryption is being adopted before they arrive.
  • Cybersecurity, HCI and bioinformatics each combine computing with another discipline: law and criminology, psychology and design, or biology and medicine.
  • Moore's law — transistor counts doubling about every two years — has slowed, pushing progress toward specialized hardware and better algorithms.
  • Ontario university computer science programs commonly require ENG4U, MHF4U and MCV4U; college programs typically require Grade 12 English and math.
  • A portfolio of two or three finished, documented, published projects is the strongest evidence of interest and skill.