Question OOP-CTOR-0001
EasyWhat is a constructor?
- A.
A loop inside a class
- B.
A special method that runs automatically when an object is created
- C.
Show answer and explanation
Answer: B
Constructors initialise the new object's fields.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Constructors and Destructors question
What is a constructor?
A loop inside a class
A special method that runs automatically when an object is created
Answer: B
Constructors initialise the new object's fields.
A static variable
A method that deletes an object