ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What is the difference constructor and method?

user-image
تم إضافة السؤال من قبل Ramakrishna Ilavarapu
تاريخ النشر: 2014/04/15
Maria Thomas
من قبل Maria Thomas , Tech Lead , J P Morgan Chase

Constructor is the point of initialisation of any object. If an explicit constructor is not given, the class has a default no arguments constructor that is internal to it which would be called when the object is created using the new operator. Constructor does not have a return type.

In contrast a method is created by the user to do some actions on the object. It is explicitly invoked on the object. It has a return type.

shabbir hussain
من قبل shabbir hussain , Billing Analyst Consultant , Ebone Network (Private) Limited

The important difference between constructors and methods is that constructors create and initialize objects that don't exist yet, while methods perform operations on objects that already exist.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟