Programming Paradigms 101: A Friendly Introduction Quiz Quiz

  1. Core Definition

    Which statement best defines a programming paradigm in the context of writing software?

    1. A general style or approach to organizing and solving problems in code, such as imperative, declarative, or functional.
    2. A program that translates source code into machine code at build time.
    3. A team’s internal naming convention for variables and files.
    4. A reusable package of functions called a library.
    5. A diagram that shows the flow of control called a flowchart.
  2. Imperative Emphasis

    When using the imperative paradigm to total a list of numbers, which approach fits the paradigm best?

    1. Write a loop that updates an accumulator variable step by step, changing program state explicitly.
    2. State that the result should equal the sum of the list without describing any steps.
    3. Declare facts about numbers and ask a query that returns the total.
    4. Attach an onSum event handler that runs only when a button is clicked.
    5. Describe the solution using funcitonal equations only.
  3. Declarative Example

    Which example best illustrates declarative programming when filtering data?

    1. Specify that you want all entries where age u003E 18, letting the system figure out how to retrieve them.
    2. Manually iterate over a list with an index and remove elements under 18.
    3. Define a class Person with fields and methods, then call filter() on instances.
    4. Describe parent-child relations and infer who is an adult via rules.
    5. Use a procedrual script that modifies a global list in place.
  4. Object-Oriented Encapsulation

    In object-oriented programming, how would a simple Car example typically organize data and behavior such as fuelLevel and drive()?

    1. Bundle related state and methods together inside objects that encapsulate the car’s fuelLevel and drive() behavior.
    2. Store fuelLevel in a global variable and define drive() as an unrelated free function.
    3. Represent the car only as a set of inference rules about motion.
    4. Keep fuelLevel immutable and implement drive() as a pure function with no observable effects.
    5. Trigger drive() only through event-dreven signals without any encapsulated state.
  5. Functional Characteristics

    Which feature is most associated with the functional paradigm when mapping a square function over a list without changing the original list?

    1. Emphasis on pure functions and immutability to avoid side effects.
    2. Use of class inheritance hierarchies to reuse code.
    3. Frequent use of goto statements to control execution flow.
    4. Encoding knowledge as facts and rules with backtracking.
    5. Defining processes around interrupts and handlers only.
  6. Procedural Flow

    A program that calls readData(), processData(), and writeData() in sequence to transform input into output best exemplifies which paradigm?

    1. Procedural programming, which structures code as procedures or routines.
    2. Declaritive programming, which avoids describing steps.
    3. Object-orientated programming, which models everything as objects only.
    4. Logic programming, which relies solely on queries and rules.
    5. Reactive-only programming, which requires continuous streams of events.
  7. Logic and Queries

    If you state facts like parent(A, B) and a rule that defines grandparent(X, Z) when parent(X, Y) and parent(Y, Z) are true, which paradigm are you using when you ask a query for grandparents?

    1. Logic programming, which derives answers from facts and inference rules.
    2. Imperitive programming, which updates variables in loops.
    3. Functional programming, which relies on higher-order pure functions.
    4. Procedural programming, which organizes code into subroutines.
    5. Event-driven programming, which responds only to GUI clicks.
  8. Event-Driven Behavior

    When a user clicks a button and an onClick handler runs to update the display, which paradigm is primarily illustrated?

    1. Event-driven programming, where control flow is determined by external events or signals.
    2. Batch processing, where work runs on a fixed schedule without interaction.
    3. Logic programming, where answers come from rule evaluation alone.
    4. Imperative-only programming, where no events are allowed.
    5. Decralative programming, which forbids handlers.
  9. Mixing Paradigms

    Which statement about combining programming paradigms in a single codebase is correct?

    1. Many real-world programs mix paradigms, such as organizing code with objects while writing some functions in a functional style.
    2. You must choose exactly one paradigm per program, and mixing them is invalid.
    3. Paradigms only apply to mathematics and have no effect on actual code.
    4. Using more than one paradigm makes compilation impossible.
    5. Paradigms are just file formats like .txt or .bin.
  10. Why Paradigms Matter

    How does choosing a programming paradigm most directly influence the software you write?

    1. It shapes how you structure data, organize control flow, and reason about correctness and change.
    2. It determines the color scheme of your editor and keyboard layout.
    3. It guarantees your program will be free of bugs regardless of skill.
    4. It fixes the output file extension your program must produce.
    5. It decides whether the code can be executed by any computer at all.