Back to Browse

Static and Instance Block programming in java explained in tamil

61 views
Nov 7, 2024
23:54

In Java, static blocks and instance blocks are used to initialize variables or perform setup tasks, but they work differently based on their scope and timing. A static block is a block of code prefixed with the static keyword and runs only once, when the class is first loaded into memory. This is often used to initialize static variables or execute startup code for the class. On the other hand, an instance block (or instance initializer block) is a block of code that runs every time a new object of the class is created, helping initialize instance variables or perform actions specific to each instance. Static blocks execute first (before any objects are created), while instance blocks run each time an object is instantiated.

Download

0 formats

No download links available.

Static and Instance Block programming in java explained in tamil | NatokHD