What is the difference between Constructor and a method?

588    Asked by DorothyChurchill in Salesforce , Asked on Jan 9, 2020

The constructor and method look similar to each other but they aren't. The main difference between constructor and function is that constructor main purpose is to initialise the

object that is being created using a new operator. But the function's main job is to perform operations on objects that already exist. We can't call constructors directly but function can be called directly on an object

that has been already created.

Constructor can't return anything even the void but function can return anything even void.



Your Answer

Interviews

Parent Categories