Decorators & Closures interview questions

15 real Decorators & Closures questions from the Python bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

1. What is decorator?

Junior
  1. A.a callable that wraps another function to extend its behavior, applied with @ syntax above the definition
  2. B.a nested function that captures and remembers variables from its enclosing scope after that scope has returned
  3. C.a helper applied to a wrapper to copy the original function's name, docstring, and metadata onto it
  4. D.a method that receives the class itself as its implicit first argument rather than an instance
Reveal the answer + AI explanation — free account

3. Which statement is correct?

Junior
  1. A.decorator — a callable that wraps another function to extend its behavior, applied with @ syntax above the definition
  2. B.decorator — a helper applied to a wrapper to copy the original function's name, docstring, and metadata onto it
  3. C.decorator — a method bound to neither the instance nor the class, receiving no implicit first argument
  4. D.decorator — a nested function that captures and remembers variables from its enclosing scope after that scope has returned
Reveal the answer + AI explanation — free account

4. What is closure?

Mid
  1. A.a helper applied to a wrapper to copy the original function's name, docstring, and metadata onto it
  2. B.a method that receives the class itself as its implicit first argument rather than an instance
  3. C.a method bound to neither the instance nor the class, receiving no implicit first argument
  4. D.a nested function that captures and remembers variables from its enclosing scope after that scope has returned
Reveal the answer + AI explanation — free account

6. Which statement is correct?

Mid
  1. A.closure — a method bound to neither the instance nor the class, receiving no implicit first argument
  2. B.closure — a callable that wraps another function to extend its behavior, applied with @ syntax above the definition
  3. C.closure — a nested function that captures and remembers variables from its enclosing scope after that scope has returned
  4. D.closure — a method that receives the class itself as its implicit first argument rather than an instance
Reveal the answer + AI explanation — free account

7. What is functools.wraps?

Mid
  1. A.a method that receives the class itself as its implicit first argument rather than an instance
  2. B.a helper applied to a wrapper to copy the original function's name, docstring, and metadata onto it
  3. C.a nested function that captures and remembers variables from its enclosing scope after that scope has returned
  4. D.a method bound to neither the instance nor the class, receiving no implicit first argument
Reveal the answer + AI explanation — free account

9. Which statement is correct?

Mid
  1. A.functools.wraps — a method that receives the class itself as its implicit first argument rather than an instance
  2. B.functools.wraps — a helper applied to a wrapper to copy the original function's name, docstring, and metadata onto it
  3. C.functools.wraps — a nested function that captures and remembers variables from its enclosing scope after that scope has returned
  4. D.functools.wraps — a callable that wraps another function to extend its behavior, applied with @ syntax above the definition
Reveal the answer + AI explanation — free account

10. What is staticmethod?

Senior
  1. A.a nested function that captures and remembers variables from its enclosing scope after that scope has returned
  2. B.a helper applied to a wrapper to copy the original function's name, docstring, and metadata onto it
  3. C.a callable that wraps another function to extend its behavior, applied with @ syntax above the definition
  4. D.a method bound to neither the instance nor the class, receiving no implicit first argument
Reveal the answer + AI explanation — free account

12. Which statement is correct?

Senior
  1. A.staticmethod — a callable that wraps another function to extend its behavior, applied with @ syntax above the definition
  2. B.staticmethod — a method bound to neither the instance nor the class, receiving no implicit first argument
  3. C.staticmethod — a method that receives the class itself as its implicit first argument rather than an instance
  4. D.staticmethod — a nested function that captures and remembers variables from its enclosing scope after that scope has returned
Reveal the answer + AI explanation — free account

13. What is classmethod?

Senior
  1. A.a nested function that captures and remembers variables from its enclosing scope after that scope has returned
  2. B.a method that receives the class itself as its implicit first argument rather than an instance
  3. C.a helper applied to a wrapper to copy the original function's name, docstring, and metadata onto it
  4. D.a method bound to neither the instance nor the class, receiving no implicit first argument
Reveal the answer + AI explanation — free account

15. Which statement is correct?

Senior
  1. A.classmethod — a callable that wraps another function to extend its behavior, applied with @ syntax above the definition
  2. B.classmethod — a method that receives the class itself as its implicit first argument rather than an instance
  3. C.classmethod — a method bound to neither the instance nor the class, receiving no implicit first argument
  4. D.classmethod — a nested function that captures and remembers variables from its enclosing scope after that scope has returned
Reveal the answer + AI explanation — free account

Free to start

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice Decorators & Closures free