+ 3
Why constructor name same as class name
5 Answers
+ 12
Constructor creates an instance of class. The names are same so that it can be unambigously identified as the constructor. and how its get invoked implicitly when we create object of that class. It is invoked by the compiler because it has already been unambiguously identified because of its naming sheme.
+ 6
If it wouldn't be like this it would be interpreted like method
+ 4
To avoid ambiguity.
+ 1
There is no reason. It's just what the inventors decided. In other languages it's different. See the Ruby course for example.