what is the difference between static block and static
method
Answer Posted / kishore reddy
static{} blocks are executed on its own as soon as the
program starts. i.e before the main method is called where
as static() is called ONLY from another static method ie
main method.
static() has several restrictions:
1. Can ONLY call other static ()
2. MUST ONLY access static data
3. cant refer to super or this
Is This Answer Correct ? | 14 Yes | 2 No |
Post New Answer View All Answers
What is static data type in java?
what is deadlock? : Java thread
State the merge-sort principle and its time complexity.
Can we change the scope of the overridden method in the subclass?
Difference between Linked list and Queue?
What is immutable class in java?
Is it possible to use Semaphore/ Mutex in an Interrupt Handler?
What are the restriction imposed on a static method or a static block of code?
What is a map? What are the implementations of map?
os is developed in c no java is more secured then c na why dont the os developed is developed using java
What are local variables?
Write a java program to check if a number is prime or not?
What is the use of 'super' keyword inside a constructor?
What is the purpose of static methods and static variables?
What is the difference between path and classpath variables?