What is the difference between a constructor and a method? Ans. The important difference between constructors and methods are: Constructors create and initialize objects that don't exist yet, while methods perform operations on objects that already exist. Constructors can't be called directly; they are called implicitly when the new keyword creates an object. Methods can be called directly on an object that has already been created with new keyword. Constructors must be named with the same name as the class name. They can't return anything, even void (the object itself is the implicit return). Methods must be declared to return something, although it can be void. - Study24x7
Social learning Network
09 Nov 2023 10:05 AM study24x7 study24x7

What is the difference between a constructor and a method? Ans. The important difference between constructors and methods are: Constructors create and initialize objects that don't exist yet, while methods perform operations on objects that already exist. Constructors can't be...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles