What happens to a static var that is defined within a method of a class?



What happens to a static var that is defined within a method of a class?..

Answer / Paras Verma

"A static variable declared within a method in a class (method-local static) has the same behavior as one declared outside of any method or inside the class itself. However, if you declare a static variable inside a constructor, it will not be accessible until after the constructor finishes executing since constructors are also static methods."n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Write a program in java to create a doubly linked list containing n nodes.

1 Answers  


What is a heavyweight component?

1 Answers  


What is character in data type?

1 Answers  


What will happen if we cannot mention "finally" in Java Program ???

3 Answers   PWC,


How to change value in arraylist java?

1 Answers  


What is the purpose of stub and skeleton?

1 Answers  


What is the difference between applet and application?

1 Answers  


What are possible key words, we can use to declare a class?

2 Answers   Tech Mahindra,


What are jee technologies?

1 Answers  


What is the difference between constructor and method?

4 Answers  


What is difference between final and finally in java?

1 Answers   Cyient,


What are the parts of a method?

1 Answers  


Categories