Questions: Functional Programming Paradigm

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A developer argues that functional programs must be slower than imperative ones because 'creating new data structures instead of modifying existing ones wastes memory and time.' Which response best addresses this objection?

APure functions allow the compiler to safely memoize results, reorder evaluation, and parallelize execution — optimizations unavailable in imperative code — which often outweigh the cost of immutable data structures
BThe developer is correct: functional languages are always slower and are used only for academic purposes where performance is not a concern
CImmutable data structures are always more memory-efficient because structural sharing eliminates all copying overhead, making the objection entirely moot
DThe performance overhead is real but irrelevant because functional programming is only applied to small symbolic computations where execution time does not matter
Question 2 Multiple Choice

Which of the following functions violates referential transparency?

AA function that returns the current system time formatted as a string
BA function that takes an integer n and returns n squared
CA function that takes a list of integers and returns a sorted copy
DA function that takes two strings and returns their concatenation
Question 3 True / False

Higher-order functions like map, filter, and reduce allow functional programmers to express data transformations declaratively — describing what result is wanted — without specifying the step-by-step iteration that produces it.

TTrue
FFalse
Question 4 True / False

A function is considered pure in functional programming if it does not access any global variables, even if it modifies one of its input arguments in place.

TTrue
FFalse
Question 5 Short Answer

Why does immutability — prohibiting data from being modified after creation — make concurrent programs safer without requiring locks or other synchronization mechanisms?

Think about your answer, then reveal below.