18 Closures & Generators questions from the PHP bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.
Free to start: the 2-minute IT readiness check — six questions and a result.
A.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
B.an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other
C.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
D.the method that returns a copy of an anonymous function rebound to a new object and class scope, redefining what the this pseudo-variable resolves to
Answer + AI explanation with Pro
2. Which term means: "an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked"?
Junior
A.Closure bindTo
B.Reference
C.Closure
D.Generator
Answer + AI explanation with Pro
3. Which statement is correct?
Junior
A.Closure — the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
B.Closure — an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
C.Closure — an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
D.Closure — the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
Answer + AI explanation with Pro
4. What is use binding?
Mid
A.an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other
B.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
C.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
D.the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
Answer + AI explanation with Pro
5. Which term means: "the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference"?
Mid
A.use binding
B.yield
C.Closure bindTo
D.Generator
Answer + AI explanation with Pro
6. Which statement is correct?
Mid
A.use binding — an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
B.use binding — an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
C.use binding — an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other
D.use binding — the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
Answer + AI explanation with Pro
7. What is yield?
Mid
A.the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
B.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
C.the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
D.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
Answer + AI explanation with Pro
8. Which term means: "the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator"?
Mid
A.yield
B.use binding
C.Generator
D.Reference
Answer + AI explanation with Pro
9. Which statement is correct?
Mid
A.yield — an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
B.yield — the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
C.yield — the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
D.yield — the method that returns a copy of an anonymous function rebound to a new object and class scope, redefining what the this pseudo-variable resolves to
Answer + AI explanation with Pro
10. What is Generator?
Mid
A.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
B.the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
C.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
D.an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other
Answer + AI explanation with Pro
11. Which term means: "an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once"?
Mid
A.Closure
B.Closure bindTo
C.Generator
D.Reference
Answer + AI explanation with Pro
12. Which statement is correct?
Mid
A.Generator — an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
B.Generator — the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
C.Generator — an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other
D.Generator — the method that returns a copy of an anonymous function rebound to a new object and class scope, redefining what the this pseudo-variable resolves to
Answer + AI explanation with Pro
13. What is Closure bindTo?
Senior
A.the method that returns a copy of an anonymous function rebound to a new object and class scope, redefining what the this pseudo-variable resolves to
B.the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
C.the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
D.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
Answer + AI explanation with Pro
14. Which term means: "the method that returns a copy of an anonymous function rebound to a new object and class scope, redefining what the this pseudo-variable resolves to"?
Senior
A.use binding
B.Closure bindTo
C.Reference
D.yield
Answer + AI explanation with Pro
15. Which statement is correct?
Senior
A.Closure bindTo — the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
B.Closure bindTo — the method that returns a copy of an anonymous function rebound to a new object and class scope, redefining what the this pseudo-variable resolves to
C.Closure bindTo — an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
D.Closure bindTo — an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
Answer + AI explanation with Pro
16. What is Reference?
Senior
A.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
B.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
C.the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
D.an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other
Answer + AI explanation with Pro
17. Which term means: "an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other"?
Senior
A.yield
B.Closure bindTo
C.Reference
D.use binding
Answer + AI explanation with Pro
18. Which statement is correct?
Senior
A.Reference — an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
B.Reference — an alias created with an ampersand so two variable names point to the same underlying storage, where assigning through one changes the value seen by the other
C.Reference — the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
D.Reference — the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
Answer + AI explanation with Pro
Free to start
Start with a free readiness check
Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Closures & Generators question come with Pro.