Can you declare a static variable in a method?

Answer Posted / venkatesh

No we can't declare a static variable in a method.
only final and default scope variables are allowed inside
the method

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is instanceof operator used in java?

597


How do you sort in descending order in java using collections sort?

503


If an object reference is set to null, will the garbage collector immediately free the memory held by that object?

639


What is object in java?

536


what do you understand by synchronization? Or what is synchronization and why is it important? Or describe synchronization in respect to multithreading? Or what is synchronization? : Java thread

490






What is strings in java?

591


How do you insert a line break?

499


Describe method overriding

589


What is the java project architecture?

1787


What are the pillars of java?

490


Can a static block throw exception?

660


What is the lifetime and scope of a variable?

520


Which sorting algorithm is best in java?

538


Can we have static methods in an interface?

569


What are the loops in java?

526