153k views
4 votes
The constructor signature is defined as the constructor __________ followed by the __________.

a. name, parameter list
b. name, return type
c. definition, body
d. definition, parameter list
e. header, body

User Hstdt
by
5.2k points

1 Answer

4 votes

Answer:

The constructor signature is defined as the constructor name followed by the parameter list.

Step-by-step explanation:

In object oriented programming, a class constructor is a special method that will run automatically whenever a new object is created from the class. The constructor name is same with the class name. Besides, the class constructor is often used to initialize the attributes with initial values. Those initial values are held by the parameter list of the constructor.

One example of the constructor defined in a Java class is as follows:

// class name

public class BankAccount {

// attribute names

private String holder;

private double amount;

// constructor name

public BankAccount(String holder, double amount) // parameter list

{

this.holder = holder;

this.amount = amount

}

}

User Berit Larsen
by
4.8k points