Can you declare a static variable in a method?

Answer Posted / ali

No Static Variable cannot declare in method.
but the method present in class can access the static variable
of class.
Or the method which is trying to access the static variable of
class but method is not part of that class at that time declare method as static then it can access that static variable.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between identifier and variable?

754


Which is faster string or stringbuilder?

724


How can I debug the Java security exceptions and AccessControlExceptions?

917


Explain the difference between call by refrence and call by value?

800


What are static blocks and static initalizers in java ?

789


Explain covariant method overriding in java.

797


Can you make a constructor final?

799


What is a parameter used for?

745


Differece between class and generic class?

804


Explain the difference between an object-oriented programming language and object-based programming language?

777


What is pre increment and post increment in java?

722


What is the escape character in java?

742


What are local variables?

822


Outline the major features of java.

820


What methods are used to get and set the text label displayed by a button object?

799