0
what is the difference between static method and static block?
4 odpowiedzi
0
Static Methods
static methods can access class variables without using object of class
Static Block
static block is used for changing the default values of static variables.A class can have multiple static blocks
0
static blocks are automatically executed when program control goes to class and for static method we have to call by using class name
0
Static method
- A static method belongs to the class rather than object of a class.
- A static method can be invoked without the need for creating an instance of a class.
- Static method can access static data member and can change the value of it.
Static block
- Is used to initialize the static data member.
- It is executed before main method at the time of classloading.
0
thanks