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 the use of java?

520


What 5 doubled?

498


What do you understand by classes in java?

540


What is difference between arraylist and list in java?

570


What is nested class?

554






How do you classify Dialog Box?

634


How many bits is a string in java?

559


What is sleep method?

612


Is null false in java?

693


Explain about sets?

555


Is string thread safe in java?

564


Explain with example the concept of constant variable in java.

608


What is the function of java?

508


What is java in layman terms?

513


Why multiple inheritance is not supported by java?

500