in Education by (55.8k points)
What is the static block?

1 Answer

0 votes
by (55.8k points)
Static block is used to initialize the static data member. It is executed before the main method, at the time of classloading.

class A2{  

  static{System.out.println("static block is invoked");}  

  public static void main(String args[]){  

   System.out.println("Hello main");  



Test it Now

Output: static block is invoked

       Hello main

Related questions

0 votes
asked Feb 18 in Education by JackTerrance (1.8m points)