1. Home
  2. Data Science
  3. Python
  4. What does the @dataclass decorator generate automatically…

Added 25 Nov 2026

What does the @dataclass decorator generate automatically in Python?

  1. A database table
  2. A JSON file
  3. __init__, __repr__ and __eq__ methods Correct answer
  4. A thread

Correct answer

C. __init__, __repr__ and __eq__ methods

5 views

MCQSEXAM

Explanation

dataclasses reduce boilerplate by generating common special methods.

Reference

Asked in: Python Interview OOP

https://docs.python.org/3/tutorial/classes.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs