Foundations of Functional Programming in Backend Development Quiz

  1. Pure Functions Identification

    Which function is considered 'pure' in functional programming?

    1. A function that returns output only based on input and has no side effects.
    2. A function that modifies a global variable as it runs.
    3. A function that logs values to the console every time it executes.
    4. A function that randomly generates different results for the same input.
    5. A function that pauses execution for a specified amount of time.
  2. Immutability Concept

    Why does functional programming emphasize immutability when handling data in backend development?

    1. It prevents accidental changes and makes code more predictable.
    2. It increases the frequency of syntax errors.
    3. It allows data structures to be modified directly.
    4. It encourages the use of mutable variables everywhere.
    5. It disables all program modifications at runtime.
  3. First-Class Functions

    What does it mean when functions are described as 'first-class citizens' in a programming language?

    1. Functions can be assigned to variables and passed as arguments.
    2. Functions must always be global in scope.
    3. Functions can only return numeric values.
    4. Functions are not allowed as arguments to other functions.
    5. Functions can only be executed directly, not assigned.
  4. Higher-Order Functions Usage

    Which statement best describes a higher-order function in backend development?

    1. A function that accepts another function as an argument or returns a function.
    2. A function that always returns null.
    3. A function only used for mathematical operations.
    4. A function defined as a constant and never changed.
    5. A function that cannot be called recursively.
  5. Side Effects Explanation

    In functional programming, which of the following is an example of a side effect?

    1. Updating a database record inside a function.
    2. Calculating the square of a number without modifying anything else.
    3. Returning a sum of two parameters.
    4. Calling a function that only reads its inputs.
    5. Sorting an array without altering the original data.
  6. Referential Transparency

    What property is satisfied if a function always produces the same output for the same input?

    1. Referential transparency
    2. Iterative consistency
    3. Contextual flexibility
    4. Mutability invariance
    5. Reflected constancy
  7. Currying Recognition

    When a function transforms a function with multiple arguments into a sequence of functions each with one argument, what is this technique called?

    1. Currying
    2. Boiling
    3. Stirring
    4. Churning
    5. Concretizing
  8. Recursion in Functional Programming

    Why is recursion commonly used over traditional loops in functional programming languages for backend development?

    1. Because recursion avoids mutable state and is compatible with immutability.
    2. Because traditional loops run much faster.
    3. Because recursion requires global variables to manage state.
    4. Because recursion cannot be implemented with pure functions.
    5. Because recursion inherently produces side effects.
  9. Function Composition Explanation

    What does function composition allow you to do in functional programming?

    1. Combine small functions into more complex functions by chaining them together.
    2. Alter the syntax of a function dynamically.
    3. Convert functions into classes during runtime.
    4. Force a function to execute multiple times automatically.
    5. Replace all variables inside functions automatically.
  10. Functional Approach Advantages

    Which is a primary advantage of using the functional programming paradigm in backend development?

    1. Improved code readability and ease of testing due to pure functions.
    2. The necessity to rely on global mutable states.
    3. Automatic conversion of all data to binary.
    4. Mandatory use of infinite loops.
    5. Increased use of side effects within business logic.