Computer Science, asked by Suga41977, 4 months ago


City =make city (name, lat, lon) Here _______is the constructor name.
a)City b)name c)city = make city d)make city ​

Answers

Answered by dreamrob
0

Answer:

If we are writing a program in Java or C++, in both the name of the constructor is the same as the name of the class.

And in python __init__() is the method that is the constructor and is called automatically when the object is created.

Creating an object of a class in C++:

In the case of non parameterized constructor

Class_Name object_name;

In the case of parameterized constructor

Class_Name object_name(a, b)

Creating object of a class in Java:

In case of non parametrized constructor

Class_Name object_name = new Class_name();

In case of parametrized constructor

Class_Name object_name = new Class_name(a, b);

Creating object of a class in Python:

In case of non parametrized constructor

object_name = Class_Name()

In case of parametrized constructor

object_name = Class_Name(a, b)

In the question, the format of creating an object is similar to that of how we create an object in python.

City = makecity (name, lat, lon)

City → Object

makecity → Class name

name, lat, lon → Parameters

So, The constructor name should be __init__()

Similar questions