Instance initialization block

Theory:
            1.An instance initialization block in a class is executed when the class is instanced.
            2. There no usage of 'return' keyword in initialization block(static/instance).
            3.Instance initializers are permitted to refer to current object 'this' keyword and  super class by 'super' keyword.

            E.g:
                 class X
                          {
                             {
                           System.out.println("Iron man suit no-1");
                              }
                          }
                 class Y extends X
                           {
                              {
                           System.out.println("Iron man suit no-2");
                               }
                            }
                 class Z extends Y
                           {
                               {
                            System.out.println("Iron man suit no-3");
                                }
                            }
                         Public class IronManSuitSeries
                           {
                              public static void main(String[] args)
                               {
                                 Z z=new Z();
                                }
                            }

Output:
          
               Iron man suit no-1
               Iron man suit no-2
               iron man suit no-3

[hints:It is a typical example of a instance initialization block .
Actually initialization blocks are the 1st line of constructor. ]
                 
                  
         

No comments

Is a unit doublet function an even function or odd function?

Dirac’s delta function is defined by the following property  δ(t) = 0 at t !=0            ∞ at t=0. The derivative of an even fu...