What is “referential transparency” in functional programming?

What is “referential transparency” in functional programming?

a) The ability to reference global variables
b) When a function consistently yields the same result given the same inputs
c) A property of functions that return nothing
d) The use of object-oriented features in functions

Answer:

b) When a function consistently yields the same result given the same inputs

Explanation:

Referential transparency means that a function will always return the same result when called with the same arguments, making the code more predictable and easier to reason about.

Reference:

Functional Programming Quiz – MCQ Questions and Answers

Scroll to Top