What is the purpose of a parameterized constructor in Java?

  • It initializes class-level variables with default values.
  • It allows the creation of multiple instances of the same class.
  • It accepts one or more arguments to initialize instance variables.
  • It is used to create static objects.
In Java, a parameterized constructor is used to initialize instance variables with values provided as arguments during object creation. This allows objects to be created with different initial states. Option 1 is incorrect as the default constructor initializes class-level variables, not parameterized constructors. Options 2 and 4 are not accurate descriptions of parameterized constructors.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *