answersLogoWhite

0

What is the use of constructors?

Updated: 8/17/2019
User Avatar

Vasavi960

Lvl 1
14y ago

Best Answer

Constructors are used in object-oriented programming languages to create usable instances of abstract data types (classes).

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the use of constructors?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why you use constructors?

To create an instance of the class that implementing that constructor


For what purpose constructors are used in Java?

Constructors are used to create the instance of a class.


When was Worshipful Company of Constructors created?

Worshipful Company of Constructors was created in 1985.


Why do you use constructors?

A constructor lets you write code that will be executed when the class is instantiated with the "new" keyword.


Are constructors inherited?

Constructors, static initializers, and instance initializers are not members and therefore are not inherited.


Is it true that the constructors of the Lighthouse of Alexandria had to use glass to stabilize its basement against the salt water?

yes


What are different type of constructor in java?

Every class, including abstract classes, MUST have a constructor. The different types are: a. Regular constructors b. Overloaded constructors and c. Private constructors


What actors and actresses appeared in Constructors - 2013?

The cast of Constructors - 2013 includes: Rauf Khabibullin as Rauf


What is a constructor with value zero?

Constructors have no value, zero or otherwise. That is, constructors cannot return a value. This is because constructors are not functions in the sense you cannot call a constructor directly. Constructors are invoked in the background when you instantiate an object of the class, thus any return value would be lost in the background, and would therefore not be visible to the invokee.


How many constructors can c have?

A class can have any number of constructors, as far as they are having different parameters or different number of parameters. For example, a class A can have following constructors & even more: A() -the default constructor A(A objectA) -the copy constructor A(int p) A(int p1, int p2) A(int[] p1, float p2) A(double p1, double p2, int p3) A(A objA, int[] p) A(B objB)


Do boa constructors eat birds?

( . Y . ) :)


How many constructors may be defined for a class?

As many as are required for the class to function. All classes other than static classes require at least one constructor. Most classes will also provide copy and move constructors (with corresponding copy and move assignment operators). Additional constructors are usually provided to increase the flexibility of the class, allowing users a variety of ways to initialise objects of the class. Constructors that accept just one argument (excluding the copy and move constructors) are regarded as being conversion constructors because, from a user's perspective, they effectively convert their argument into an object of the class. Although there is effectively no limit to the number of constructors you can define, do keep in mind the mantra that simple concepts should be expressed simply and no simpler. Make good and proper use of inline initialisation, default arguments and delegation. Use explicit constructors to avoid narrowing issues and implicit conversions where narrowing is acceptable. Also, make good use of RAII (resource acquisition is initialisation) to ensure proper cleanup should any member fail to initialise during construction. For efficiency, perform as much initialisation as possible outside the body of the constructor. Ideally, the constructor body should contain no code at all.