why we cannot declare static variable inside a static method

Answers were Sorted based on User's Feedback



why we cannot declare static variable inside a static method..

Answer / ravikiran

Because all the variales inside static method are by
default static

Is This Answer Correct ?    15 Yes 4 No

why we cannot declare static variable inside a static method..

Answer / srinu

generally all variables inside static method treated as
static

Is This Answer Correct ?    9 Yes 3 No

why we cannot declare static variable inside a static method..

Answer / sachin kanojiya

Static variable initializes at the time of class load
(static variable initialize very first,after that static
method)that means static variable and method already define
but inside the static method can't declare static variable
because it is treat as static local member...

Is This Answer Correct ?    5 Yes 4 No

why we cannot declare static variable inside a static method..

Answer / swamireddy

STATIC VARIABLES ARE DECLARED CLASS DIFINITION ONLY
WITHOUT DECLARE THE WITHIN STATIC METHODS.THE STATIC
METHODS ARE ONLY USE THE STATIC VARIABLES.

Is This Answer Correct ?    2 Yes 2 No

Post New Answer

More Core Java Interview Questions

How many objects are created when we create String class object using new operator?

9 Answers   Mind Tree,


What is the default size of set in java?

0 Answers  


What does it mean that a method or field is “static”?

0 Answers  


in a constructor what happen if u call super and this in the same class? i know that it is not possible to call both in the same one? if we call what will happen?

10 Answers   ITC Infotech,


Explain break statement and continue statement?

3 Answers  


Why is multithreading important?

0 Answers  


What data type is true or false?

0 Answers  


What are keyboard events?

0 Answers  


How to display arraylist values in java?

0 Answers  


How a string is stored in memory?

0 Answers  


How to override equals() and hashCode() method in java?

1 Answers   Wipro,


Define max and min heap, also the search time of heap.

0 Answers   GrapeCity,


Categories