A function that is called automatically each time an object is created is a(n)

constructor
contractor
builder
architect

The correct answer is A. constructor.

A constructor is a special type of function that is called automatically when an object is created. It is used to initialize the object’s state and to perform any other necessary tasks.

A contractor is a person who contracts to do work for another person or company. A builder is a person who builds structures, such as houses or buildings. An architect is a person who designs structures, such as houses or buildings.

Here is an example of a constructor in Python:

“`python
class Person:
def init(self, name):
self.name = name

p = Person(“John Doe”)
print(p.name) # prints “John Doe”
“`

In this example, the Person class has a constructor called __init__(). When an object of type Person is created, the __init__() function is called automatically. The __init__() function takes one argument, which is the name of the person. The __init__() function assigns the value of the argument to the name attribute of the object.

I hope this helps!

Exit mobile version