Explain constructors.
What will be an ideal response?
A method that has the same name as a class and that establishes an object is a constructor method, or more simply, a constructor. Constructors fall into two broad categories:A default constructor is one that requires no arguments.A non-default constructor or a parameterized constructor requires arguments.All non-default constructors are written by a programmer, but there are two categories of default constructors:An automatically-created default constructor exists in a class in which the programmer has not explicitly written any constructors.A programmer-written default constructor can reside in any class and replaces the automatically-created one.In object-oriented programming (OOP) languages, you can write both default and nondefault constructors for a class; if so, the constructors are overloaded.
You might also like to view...
Usually an e-mail address is provided by a(n) ________
Fill in the blank(s) with correct word
If grade is an array, trying to store its address using the expression &grade results in a ____.
A. program crash B. normal execution C. compiler error D. scaling error