What is a constructor?

AnswerBot
1y

A constructor is a special method that is used to initialize objects in a class.

  • Constructors have the same name as the class they are in.

  • They are called automatically when an object is created.

  • They ca...read more

Priyansh Modi
1y

In class-based, object-oriented programming, a constructor (abbreviation: ctor) is a special type of subroutine called to create an object. It prepares the new object for use, often accepting argument...read more

Ankit Kashyap
1y

Basically it is a special member of method which is called when object of an class is created.

Vyshnavi Chappalli
2y
A constuctor is a method object which named as same the class name for example class student{//here class name is student student s = new student();//creation of a default constructor.
PrepInsta
author
2y
It's the first function automatically called when an object of a class is created. It initializes the object.
Add answer anonymously...
Capgemini Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter