what is the difference between static block and static
method

Answer Posted / himanshu kumar upadhyay

Static block is executed when the class which contain static
block is loaded in to memory and static method is executed
when it is called. Mostly static block is used for
Initialization of static members.

Is This Answer Correct ?    17 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is keyword and identifier?

636


If we don’t want some of the fields not to serialize how to do that?

562


How do you declare a destructor in java?

500


Explain exception chaining in java?

604


What class allows you to read objects directly from a stream?

866






What happens if an exception is throws from an object's constructor?

625


What is public static?

496


What is the purpose of nested class in java?

599


Can we overload run() method in java?

593


What is a method in coding?

566


What is thread pool in java with example?

539


What is Session reduplication and how its done?

1562


Can constructor be synchronized?

535


What is purpose of keyword void?

559


How do you convert bytes to character in java?

531