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 declare a constructor as final?
Why 1 is not a prime number?
What is api data?
What is the use of keywords in java?
What is the difference between member variables initialization and assignment in a constructor?
How will you invoke any external process in java?
What is difference between next () and nextline () in java?
What are the differences between stringbuffer and stringbuilder?
what is meant by encapsulation?
What java is used for?
What are the important features of Java 11 release?
How big is a boolean?
What does t in java mean?
Why is string buffer better than string ?
What is vector?