+ 1

What is the difference between constructor and method

4th Mar 2017, 9:06 PM
kabelo
kabelo - avatar
2 ответов
+ 1
Constructor is called when an object of the class is created. Method needs to be called manually. example: constructor of class A gets called when object of the class is created: A objName = new A(parametersForConstructorIfAny); then you can call method in the class: objName.someMethod();
4th Mar 2017, 9:11 PM
David Koplik
David Koplik - avatar
0
in constructor u can"t have return type
5th Mar 2017, 6:33 AM
Somnath Ghosh
Somnath Ghosh - avatar