Closures & Generators interview questions

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.

Take the free IT readiness check

or take a mock interview set up for this area

1. What is Closure?

Junior
  1. A.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
  2. 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
  3. C.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
  4. 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
  1. A.Closure bindTo
  2. B.Reference
  3. C.Closure
  4. D.Generator

Answer + AI explanation with Pro

3. Which statement is correct?

Junior
  1. 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
  2. B.Closure — an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
  3. 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
  4. 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
  1. 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
  2. B.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
  3. C.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
  4. 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
  1. A.use binding
  2. B.yield
  3. C.Closure bindTo
  4. D.Generator

Answer + AI explanation with Pro

6. Which statement is correct?

Mid
  1. 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
  2. B.use binding — an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
  3. 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
  4. 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
  1. A.the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
  2. B.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
  3. C.the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
  4. 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
  1. A.yield
  2. B.use binding
  3. C.Generator
  4. D.Reference

Answer + AI explanation with Pro

9. Which statement is correct?

Mid
  1. 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
  2. B.yield — the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
  3. 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
  4. 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
  1. A.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
  2. B.the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
  3. C.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
  4. 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
  1. A.Closure
  2. B.Closure bindTo
  3. C.Generator
  4. D.Reference

Answer + AI explanation with Pro

12. Which statement is correct?

Mid
  1. 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
  2. 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
  3. 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
  4. 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
  1. 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
  2. B.the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
  3. C.the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
  4. 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
  1. A.use binding
  2. B.Closure bindTo
  3. C.Reference
  4. D.yield

Answer + AI explanation with Pro

15. Which statement is correct?

Senior
  1. A.Closure bindTo — the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
  2. 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
  3. 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
  4. 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
  1. A.an anonymous function object that can capture variables from the scope in which it was defined for later use when invoked
  2. B.an object that implements iteration by producing values one at a time on demand, avoiding building an entire collection in memory at once
  3. C.the clause attached to an anonymous function that explicitly imports outer-scope variables, by value unless prefixed with an ampersand for a reference
  4. 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
  1. A.yield
  2. B.Closure bindTo
  3. C.Reference
  4. D.use binding

Answer + AI explanation with Pro

18. Which statement is correct?

Senior
  1. 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
  2. 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
  3. C.Reference — the keyword that pauses a function and emits a value to the caller, turning that function into a lazily iterated generator
  4. 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.

Take the free IT readiness check

or take a mock interview set up for this area

24,000+ questions & coding problemsSoftware & IT16,274 questionsGovernment jobs26 examsAptitudenew questions every timeAI practice interviewwith feedback65 topics to practiseMechanical1,149 questionsGATE ME9 papersEngineering Mathematics381 questions2-minute checkfreeDSA Problems1,422Civil1,005 questionsGATE CE9 papersCS Fundamentals1,209 questionsYour scores6 skillsSystem Design25Electrical / EEE1,047 questionsGATE EE9 papersRun your codeC++ · Java · PythonLow-Level Design144Electronics & Comm.975 questionsGATE EC9 papersAI help on every questionFull-Stack6,282Chemical1,005 questionsGATE CH9 papersAI whiteboardsystem designWork abroadEurope · remote · transfersESE ME1 paperGATE practice papers2019–2026ESE CE1 paperDate alertsbefore the last dateESE EE1 paperBehavioural courseHR round practiceESE ET1 paperResume optimizerProSSC JE ME1 paperApplication trackerSSC JE CE1 paperCompany-wise prepSSC JE EE1 paperRole roadmapsRRB JE1 subjectPriced in ₹UPI · cardsISRO SC1 paperGATE CS9 papersIBPS SO IT1 paperUGC NET CS1 paperSSC CGL26 papersIBPS PO26 papersRRB NTPC26 papersSSC CHSL26 papersIBPS Clerk26 papersSBI Clerk26 papersRRB Group D26 papersSSC CPO26 papersSSC GD26 papers