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
Can we have a try block without catch block?
What is the use of beaninfo?
What happens if we override private method?
Explain working of call by reference function invoking.
What is command line used for?
How are multiple inheritances done in Java?
How can we make a class virtual?
Why null value is used in string?
what is optional in java 8?
What is the use of parse function in java?
What is an argument in java?
Can you instantiate the math class in Java?
What is == in java?
What is the use of singleton?
Can you override a final method?