Qus:    What is the static block?
Feb 19, 2021 11:07 1 Answers Views: 9 SANJAY
Prev Next
Answers (1)
VAMSI Feb 20, 2021 09: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 what course is right for you?

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


Let`s Connect