Organizational Research By

Surprising Reserch Topic

Question:What is the difference between a constructor and a method?



asked Sep 13, 2013 in Java Interview Questions by anonymous
edited Sep 12, 2013
0 votes
118 views



Related Hot Questions

2 Answers

0 votes
A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator. A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.
answered Sep 13, 2013 by anonymous
edited Sep 12, 2013
0 votes
A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator. A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.
answered Sep 13, 2013 by anonymous
edited Sep 12, 2013

...