Can you declare a static variable in a method?

Answer Posted / ali

No Static Variable cannot declare in method.
but the method present in class can access the static variable
of class.
Or the method which is trying to access the static variable of
class but method is not part of that class at that time declare method as static then it can access that static variable.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a conditional statement explain with example?

544


How many bytes are there?

544


What is data object example?

535


What are the two ways to create a thread?

538


What is a null check?

539






What is bytecode verifier?

507


What is the purpose of declaring a variable as final?

489


What are the 4 types of research methods?

515


Give any two differences between C++ and java.

562


What is the difference between preemptive scheduling and time slicing?

595


Why do we use threads in java?

569


Can we use String with switch case?

673


Why singleton class is used in java?

576


Why for each loop is used?

508


What are the differences between heap and stack memory?

554