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 are the components of awt in java?
Is java a high level language?
Which one should we prefer while using bean ? managed bean annotation or faces-config
What is javaserver pages standard tag library (jstl)?
What are the main components of the j2ee application?
How java is reliable?
Hi friends can you give me sample code for Entire j2ee web application with struts and hibernate.I mean code for Dao, DaoImpl, HibernateDao ,HibernateDaoImpl, Dto , service , ServiceImpl , i.e.
Is j2ee a programming language?
Hi Friends. I want complete technical flow of j2ee project with following technologies. jsp , servlet , Struts , Hibernate , (should follow mvc-2 design pattern) . with DAO ,DTO SERVICE layers .
What is source file in java?
What are the modules of j2ee?
What is data?