Prev Next
Answers (1)
Solem Antola Feb 20, 2021 15:45
Answer:   Static block is used to initialize the static data member. It is executed before the main method, at the time of classloading.
1. class A2{
2. static{System.out.println("static block is invoked");}
3. public static void main(String args[]){
4. System.out.println("Hello main");
5. }
6. }
7. Output: static block is invoked
8. Hello main

Post Your Answer
Guest User

Not sure whare to join tuition right for you?

Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.


Let`s Connect