answersLogoWhite

0


Best Answer

A parameterized constructor allows the programmer who uses the object to pass parameters. For example, without paramters, the creation of a point in 2-dimensional space might look like this (I am omitting the definition of the class; but you have to create the class as well): Point startingPoint = new Point(); startingPoint.x = 5.0; startingPoint.y = 2.0; Or like this: Point startingPoint = new Point(); startingPoint.setCoordinates(5.0, 2.0); A constructor with parameters makes it possible to use this syntax, which is shorter: Point startingPoint = new(Point(5.0, 2.0); The constructor in this case must assign the parameters to the "x" and "y" fields.

A parameterized constructor allows the programmer who uses the object to pass parameters. For example, without paramters, the creation of a point in 2-dimensional space might look like this (I am omitting the definition of the class; but you have to create the class as well): Point startingPoint = new Point(); startingPoint.x = 5.0; startingPoint.y = 2.0; Or like this: Point startingPoint = new Point(); startingPoint.setCoordinates(5.0, 2.0); A constructor with parameters makes it possible to use this syntax, which is shorter: Point startingPoint = new(Point(5.0, 2.0); The constructor in this case must assign the parameters to the "x" and "y" fields.

A parameterized constructor allows the programmer who uses the object to pass parameters. For example, without paramters, the creation of a point in 2-dimensional space might look like this (I am omitting the definition of the class; but you have to create the class as well): Point startingPoint = new Point(); startingPoint.x = 5.0; startingPoint.y = 2.0; Or like this: Point startingPoint = new Point(); startingPoint.setCoordinates(5.0, 2.0); A constructor with parameters makes it possible to use this syntax, which is shorter: Point startingPoint = new(Point(5.0, 2.0); The constructor in this case must assign the parameters to the "x" and "y" fields.

A parameterized constructor allows the programmer who uses the object to pass parameters. For example, without paramters, the creation of a point in 2-dimensional space might look like this (I am omitting the definition of the class; but you have to create the class as well): Point startingPoint = new Point(); startingPoint.x = 5.0; startingPoint.y = 2.0; Or like this: Point startingPoint = new Point(); startingPoint.setCoordinates(5.0, 2.0); A constructor with parameters makes it possible to use this syntax, which is shorter: Point startingPoint = new(Point(5.0, 2.0); The constructor in this case must assign the parameters to the "x" and "y" fields.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

A parameterized constructor allows the programmer who uses the object to pass parameters. For example, without paramters, the creation of a point in 2-dimensional space might look like this (I am omitting the definition of the class; but you have to create the class as well): Point startingPoint = new Point(); startingPoint.x = 5.0; startingPoint.y = 2.0; Or like this: Point startingPoint = new Point(); startingPoint.setCoordinates(5.0, 2.0); A constructor with parameters makes it possible to use this syntax, which is shorter: Point startingPoint = new(Point(5.0, 2.0); The constructor in this case must assign the parameters to the "x" and "y" fields.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why do you need the parameterised constructors and also why there is a need for the constructors?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How are parametrized constructor different from non parametrized constructor?

Parameterised constructors accept arguments while non parameterised constructors do not. Example : class A { A(){ // non parameterised ... } A(int b){ // parameterised ... } }


What are types of constructors?

there are two types of constructure. 1. Default constructure 2. Parameterised constructure


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.


What is main advantage of using constructors in java?

Constructors have the same name as the class itself and they do not specify a return type, not even void because they return the instance of the class itself. Because constructors have the same name as the class then they allow method overloading and also save memory and execution time of program. Program release memory of constructors function after using this function and it reduce program complexity.


Are constructors inherited?

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


How can you identify a constructor from among any other methods in a class?

Constructors have the same identifier as that of the class, so if the name of your class is Book then your constructor must also be named Book. Constructors have no return type, not even void.


What is the difference between default constructor and parameterized constructor?

A default constructor is one that has no parameters (C++ also calls constructors with all default parameters a default constructor), while a parameterized constructor is one that has at least one parameter without a default value. Default constructors can be provided by the compiler if no other constructors are defined for that class or any class the class inherits from, while parameterized constructors must always be defined by the developer.


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.


What is the use of constructors?

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