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 static data type in java?

0 Answers  


what is difference between Action messages and Action errors?

3 Answers   Bio Imagene, TCS,


What is variable in java?

0 Answers  


How do you check if a character in a string is a digit or letter?

0 Answers  


Compare Mutex and Semaphore in java.

0 Answers   Ciena,






What is the importance of main method in Java?

0 Answers  


how to one war file class to another war file class?

0 Answers  


What is Marker interface in java? and what is clone?

16 Answers   Persistent, Wipro,


What are uses of Hash Code?

2 Answers   Cognizant,


What is bigger kb or mb?

0 Answers  


program to validate the IP address? Validity range should be 0 to 255

1 Answers   Huawei,


What are the states of thread in java?

0 Answers  


Categories