Beginner
Compilers & Programming Language Theory
Q33 / 100
What is a closure in programming languages?
Correct! Well done.
Incorrect.
The correct answer is B) A function together with its captured environment — variables from the enclosing scope it can access after that scope has exited
B
Correct Answer
A function together with its captured environment — variables from the enclosing scope it can access after that scope has exited
Explanation
Closures capture variables from enclosing scope. In Python: def make_adder(x): return lambda y: x+y. The returned lambda closes over x. Used for callbacks, higher-order functions, and state encapsulation.
Progress
33/100