Can you declare a static variable in a method?

Answer Posted / aravinda reddy

No we can't declare a static variable in a method or static
method, static variables are class level variables. Static
means one per class as per OO rules and method level
variables scope is with in the method. So if java allows
static variable inside a method, static concept is useless.

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is reflexive association?

1011


Why is stringbuffer thread safe?

570


How to do encapsulation in java?

574


What is ternary operator?

570


Name some OOPS Concepts in Java?

642






Can we use different return types for methods when overridden?

556


How can you avoid serialization in child class if the base class is implementing the serializable interface?

641


Why 1 is not a prime number?

562


What are the application of stack?

505


What is percentage in java?

576


Is singleton set an interval?

534


What is bigger kb or mb?

589


Describe 2 different ways to concatenate two strings.

687


When arithmeticexception is thrown?

585


What is the difference between a vector & an array list?

677