The _______ block in a Java class is executed before constructors.

  • finalize
  • instance
  • main
  • static
In Java, the static block is executed before constructors. Static blocks are used for performing class-level initialization tasks. They run when the class is loaded, and they are executed only once. Constructors, on the other hand, are used to initialize instance variables and are called when an object is created.
Add your answer
Loading...

Leave a comment

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