What is meant by constructor

Showing Answers 1 - 3 of 3 Answers

Kulwant

  • Sep 12th, 2005
 

Constructor are special methods that used to perform some task/ initialization  while creating object of class. 

  Was this answer useful?  Yes

Constructors are one of the highlighting features of the oops paradigm whose name is the same as the class name. It is not a function but it consists functions. It does not have any return type. If we use constructors the memory space will be automatically allocated for that class object. ex: class Cons { Cons() //Creating a constructor { void disp() { //sts; } } public static void main(String args[]) { Cons c; //invoking the constructor c.disp(); } }

  Was this answer useful?  Yes

Constructors are one of the highlighting features of the oops paradigm whose name is the same as the class name. It is not a function but it consists functions. It does not have any return type. If we use constructors the memory space will be automatically allocated for that class object. ex: class Cons { Cons() //Creating a constructor { void disp() { //sts; } } public static void main(String args[]) { Cons c; //invoking the constructor c.disp(); } }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions