static variable is a class variable which value remains
constant for the entire class?? variable means value is
changed....hear value is not changed... why it is called
static variable
Answers were Sorted based on User's Feedback
Answer / hasan
We can change the value of Static variable but if we change it reflect the main static variable
static variable is variable which is common to all object it memory is allot once and share by all object if any change then it is reflect the main value
who sad Static viable value not change it change.........
Is This Answer Correct ? | 21 Yes | 1 No |
Answer / kavita
Only variables marked as final cannot be changed.
Static variables memory is alloted once and shared by all the objects
Is This Answer Correct ? | 9 Yes | 0 No |
Answer / singh_prabhakar
its a misconception if u think tht static variable's values
are nt changed....it does....!!!
the keyword static only means tht this variable belongs to
the class ie every object tht uses this var is using the
only copy of it wch lies with the class......unlike the
instance variable where when accessed every object enjoys a
copy for itself...
in short --in a class thr's a - "static int k=0;" n class
has three objects -"ob1,ob2,ob3" n say all tends to
increment "+2" to the value of k...then @ end after being
accessed by aal three objects the final value of "k" wud be
"6" ..!!!
[ASSUME it like a JOINT ACCOUNT IN A BANK BETWEEN TWO
SIBLINGS...transactions made by any of them is Reflected in
the shared account..]
Is This Answer Correct ? | 4 Yes | 0 No |
A variable which is declared with 'static' keyword called
"static variable" or "class variable". Because,when we
execute the java application JVM first search for the class
and it loads into the JVM's memory.Now, it open the class
and searches for static variables if JVM finds the static
variable in the class then JVM will allot memory for the
static variables in HEAP area.Memory for the static
variables will be allotted only once at the time of loading
the class, that means static variable is only one per the
class.Hence, we call static variable as class variable.
Is This Answer Correct ? | 13 Yes | 12 No |
Answer / narayana
because static means class variable ,
it loads the when class variable
Is This Answer Correct ? | 0 Yes | 1 No |
What is external subset?
What is javaserver pages standard tag library (jstl)?
Which compiler is used in java?
How does javac compiler work?
Is string an object in java?
Give some advantages of orm (object-relational mapping)?
What is declarative security ?
What is component contract?
What is container-managed transaction?
Explain the j2ee tiers.
What are the most important topics in java?
What is javamail?