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 meant by abstract class?

872


Can main() method in java can return any data?

930


What is a treeset class?

792


What is the difference between method and means?

828


What does  mean in regex?

795


What are the types of literals?

833


What are the important features of Java 11 release?

828


What is linkedlist in java?

759


Define a java class.

1122


What is array initialization in java?

739


When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?

852


What is bubble sort in java?

885


Which class is the superclass of all classes?

876


List types of storage classes in java?

868


How we can run a jar file through command prompt in java?

757