117k views
0 votes
what is a constructor in java? a constructor is something that holds the private state of an instance. a constructor allows us to create a new instance of a class, usually initializing instance variables. a constructor is a method with instructions on how to use a class. a constructor is a syntax rule in java for placing curly brackets.

User Ngb
by
5.5k points

1 Answer

4 votes

Answer:

A constructor allows us to create a new instance of a class, usually initializing instance variables.

Step-by-step explanation:

When a new object is created, the constructor is called. A constructor can be used to set initial values for object attributes.

User Tomonso Ejang
by
5.0k points