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

When should you use arraylist and when should you use linkedlist?

482


Why strings in java are called as immutable?

580


Can a class be a super class and a sub-class at the same time? Give example.

778


Can we restart a thread already started in java?

568


If you do not want your class to be inherited by any other class. What would you do?

552






What is parameter example?

530


What are the changes in java.io in java 8 ?

539


What does sizeof return?

544


Why is java not 100% pure oops?

604


Is array an object in java?

539


Can we sort array in java?

517


What is bool mean?

554


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

558


Can a java program have 2 main methods?

534


Explain the importance of import keyword in java?

515