Virajsinh

Java_12

Feb 11th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. //Write A Java Program To Explain the Consept Of Initializer And Class Initializer
  2.  
  3. class Ex12 // Ex12 is FileName
  4. {
  5.     int speed;
  6.  
  7.     //#Third Priority
  8.     Ex12()
  9.     {
  10.         System.out.println("Constructor is invoked");
  11.     }
  12.  
  13.     //#Second Priority
  14.     //Initializer Call Every Time After Class
  15.     //Initializer no Need to name
  16.     {
  17.         System.out.println("Instance Initializer Block invoked");
  18.     }
  19.    
  20.     //#First Priority
  21.     //Class Call Only One Time
  22.     static
  23.     {
  24.         System.out.println("Class Initializer");
  25.     }
  26.    
  27.     public static void main(String args[])
  28.     {
  29.         Ex12 obj = new Ex12();
  30.         Ex12 obj2 = new Ex12();
  31.     }
  32. }
Add Comment
Please, Sign In to add comment