โ† All CPA Flashcard Decks

Testing, Debugging & Code Optimization Flashcards

7 cards from real CPA practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Testing, Debugging & Code Optimization flashcards as text
  1. What is 'mocking' in unit testing?

    Answer: Replacing a dependency with a fake that records how it was called

    A mock replaces a real dependency and also verifies that specific methods were called with expected arguments during the test.

  2. Which type of error is detected by the compiler before the program runs?

    Answer: Syntax error

    Syntax errors violate the grammatical rules of the programming language and are caught by the compiler or interpreter before execution begins.

  3. What does 'test-driven development' (TDD) require you to do first?

    Answer: Write a failing test before writing code to pass it

    TDD follows a red-green-refactor cycle: write a failing test first, then write the minimum code to make it pass, then refactor.

  4. Which data structure typically provides O(1) average-case lookup and is commonly used for caching optimizations?

    Answer: Hash table

    Hash tables map keys to values using a hash function, providing O(1) average-case lookup and making them ideal for caching and memoization.

  5. What is 'dead code' in software?

    Answer: Code that is never executed during normal program operation

    Dead code is source code that can never be reached or executed, often left over from refactoring, and should be removed to reduce maintenance burden.

  6. What is the purpose of an assertion in a unit test?

    Answer: To verify that an actual value matches the expected value

    Assertions compare actual results to expected values and cause the test to fail with a clear message if they do not match.

  7. Which profiling approach samples the call stack at regular intervals to estimate where time is spent?

    Answer: Statistical (sampling) profiling

    Statistical profiling periodically samples the program's call stack, estimating hot spots without requiring code instrumentation, resulting in lower overhead.