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
How can we find the sum of two linked lists using stack in java?
What is bitwise complement?
What is passing parameters in java?
how is final different from finally and finalize in java?
What are singleton services?
How can you handle java exceptions?
Can a class be declared as static?
What are the types of inner classes (non-static nested class) used in java?
What is meant by method overriding?
What are the steps in the jdbc connection?
What is singleton class in ruby?
How can an object be unreferenced?
How much ram can a 64 bit processor theoretically?
What is the benefit of inner / nested classes ?
Can a static block throw exception?