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 main use of generics in java?

510


What is passing parameters in java?

526


Can I declare class as static or private?

545


What is the difference between the final method and abstract method?

542


What is comparator in java?

559






what is the messsage u r going to get from an objectoriented programing?

1615


What data type is a string?

515


Why is sizeof not a function?

551


Is ++ operator thread-safe in java?

636


What is the difference between sop and work instruction?

487


What are the legal operands of the instanceof operator?

567


What is java Applet?

652


Is arraylist ordered?

565


What are filterstreams?

616


What is mnemonic code?

543