Can you declare a static variable in a method?

Answer Posted / vijayakumar chinnasamy

No static variable cannot be declared within static/non-
static method.

only "final" and "default" allowed within in method for
variable declaration. i.e u cant use
private,protected,public,static within method .it display
the compile time error "Illegal modifier".

Is This Answer Correct ?    11 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is constructor chaining in java?

835


Can java list be null?

763


What is the difference amongst jvm spec, jvm implementation, jvm runtime ?

735


Can string be considered as a keyword?

806


What do you mean by formatting?

753


How to perform binary search in java?

794


What is module with example?

697


What happens if an exception is throws from an object's destructor?

821


What is array length?

727


How do I know if java is installed?

789


How can you make a class serializable in java?

785


How to declare an arraylist in java?

716


What are the benefits of operations in java?

694


If you do not want your class to be inherited by any other class. What would you do?

796


What is square root in java?

799