Can constructor be private?



Can constructor be private?..

Answer / Ravinder Kumar

In Python, constructors (or special method __init__()) cannot be made private. However, you can define a private initializer using a double underscore name: `def __init__(self, ...): ...`. But it will still be accessible to subclasses and instances.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

What are python variables?

1 Answers  


Why don’t python lambda have any statement?

1 Answers  


How you can convert a number to a string?

1 Answers  


How are inheritance and overriding methods are related?

1 Answers  


What is list comprehension? Give an example.

2 Answers  


What does unittest main () do?

1 Answers  


What is flask used for in python?

1 Answers  


Where can I learn python for free?

1 Answers  


What does slicing mean in python?

1 Answers  


What is “call by reference” in python?

1 Answers  


What is keyword arguments in python?

1 Answers  


Why main method is static?

1 Answers  


Categories