206k views
2 votes
when is the init method called for an object? a.) at deletion b.) when an attribute is assigned c.) when a method is called d.) at class instantiation

User Flukeflume
by
7.3k points

1 Answer

4 votes

Final answer:

The init method is called d. at class instantiation in Python to initialize the attributes of an object.

Step-by-step explanation:

The init method, also known as the constructor method, is called at class instantiation when an object is created from a class in Python.

It is used to initialize the attributes of an object.

For example, if we have a class called Car with attributes like color and model, the init method would be called when we create a new Car object to set the initial values for these attributes.

User Ivan Bravo Carlos
by
8.1k points