Define block in java.

BLOCKS IN JAVA:—————————————————————————–

  • A block  is a set of instruction define in curly braces ({}) block doesn’t have any name so you cannot invoke the block explicitly  . block  doesn’t   have any  name so you cannot invoke by the jvm automatically.
  • Blocks define inside the class directly as member are called as intilization block.
  • there are two types of initialization block.
  • 1.Instance initialization block(IIB)
  • 2.static initialization block.(SIB).
  • Instance initialization block(IIB)——————-

Block define inside the class directly without static modifier is called as instance initialization blocks.

Instance:-

will be invoke by the jvm automatically after initializing the object .

  • creating object is necessary in IIb.
  • how much time we create abject then the same no of time of the IIb is called.
  • IIb is called when the class of object is created.

synatax

{

// IIB block

 

}

 

.

 

Leave a Reply

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