Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
4.2k views
in Computer by (26.0k points)

Explain different types of constructors.

1 Answer

+1 vote
by (25.1k points)
selected by
 
Best answer

There are three types of constructors.

  1. Namely Default constructor.
  2. Parameterized constructor.
  3. Copy constructor.

1. Default Constructor:
A constructor which does not take any arguments is called a zero argument constructor. It is also called zero-argument constructor.

Features of default constructor are:

  • All objects of a class are initialized to same set of values
  • These constructors has no arguments
  • These constructors are automatically called when every object is created.

The disadvantages of default constructor are:

  • Different objects cannot be initialized with different values.
  • Declaring a constructor with arguments hides default constructor.

2. parameterized constructor:
A constructor that takes one or more arguments is called a parameterized constructor.

The features of parameterized constructors are :

  • parameterized constructors can be overloaded
  • parameterized constructors can have default arguments and default values.

The different methods through which constructors can be invoked are implicit call and explicit call and using operator.

a. Explicit call:
It is a method of invoking a function where the declaration of object is followed by assignment operator followed by a constructor followed by argument list enclosed within parentheses.

b. Implicit Call:
It means the declarationof the object is followed by argument list enclosed in parentheses used with constructors The is used for the parameterized constructor which has exactly one argument.

3. Copy Constructor:
It is a parameterized constructor using which one object can be copied into another object. The copy constructor takes an object as argument and is used to copy values of data members of one object into other object.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...