Which of the following concepts allows Java objects to be initialized with actual data when they are created?

  • Class variables
  • Constructors with parameters
  • Default constructors
  • Initialization blocks
In Java, constructors with parameters allow objects to be initialized with actual data when they are created. Default constructors are provided by the compiler and don't take parameters. Initialization blocks are used for initializing instance variables, but they don't take external data. Class variables (static fields) are not used for initializing object-specific data.
Add your answer
Loading...

Leave a comment

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