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

In how many ways we can do exception handling in java?

573


Why null value is used in string?

521


Name few "optional" classes introduced with java 8 ?

639


What is the difference between jdk, jre, and jvm?

570


How we can declare a static variable?

650






What is collections framework?

571


What are parsers? Dom vs sax parser.

555


State the merge-sort principle and its time complexity.

569


What is a function in java?

564


What is the difference between hashset and treeset in java?

533


What is an enumeration?

566


What java is used for?

655


What are the rules for naming an array?

520


Can we have try without catch block?

637


Explain the meaning of java applet.

601