4.0k views
3 votes
This is a special function that is called whenever a new object is created and initialized with another object's data. destructor static function copy constructor assignment function None of these

User Smaranjit
by
5.0k points

1 Answer

4 votes

Answer:

constructor

Step-by-step explanation:

A constructor is a special method that initializes the fields of a class whenever a new object of that class is created with the new keyword. This method is called each time a new object is created.

In the class definition, the constructor has the same name as the name of the class and does not contain a return type, not even void.

A constructor looks like this

public class Construct {

String name;

//Constructor

Construct(){

this.name = "ijeggs";

}

}

User Workdreamer
by
5.3k points