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

What is Java Shutdown Hook?

1 Answers  


What is the difference between a choice and a list?

1 Answers  


when everything can be done by static block then why do we use main method?.

2 Answers  


Describe the term diamond problem.

1 Answers  


What is constructor in java ?

1 Answers  


What is double parsedouble in java?

1 Answers  


what should do when using multiple catch() block & what should never do for the same?

1 Answers  


How to compare strings in java?

1 Answers  


long d =10;int i =0;i=d; /// is this possible? If d is very long number (10 digits or some thing) then?

3 Answers  


Why Java doesn’t support multiple inheritance?

1 Answers  


Difference difference paint() and paintcomponent()?

1 Answers  


What is a conditional statement explain with example?

1 Answers  


Categories