what is difference between static and non-static variables
Answer Posted / mahesh_b.tech@2008
Non-static variables:
Instance block can be executed automatically when you were
creating the object.
Instance variables can be called by using with the object.
Instance variables can not called by using the class name.
memory will be alocated for instanse variables when you
create the object.
Static variables:
static block will be executed automatically when jvm(Java
Virtual Machine)loading the class into memory.
static varisble can be called using both objectname&class
name.
memory will be allocated when jvm loads the class.
Is This Answer Correct ? | 13 Yes | 4 No |
Post New Answer View All Answers
What is const pointer and const reference?
What is the best way to declare and define global variables?
Eplain extern keyword?
Is swift faster than c++?
what is Loop function? What are different types of Loops?
What is polymorphism and its type in c++?
Can a program run without main?
Explain stack unwinding.
Can user-defined object be declared as static data member of another class?
Why is polymorphism useful?
How const int *ourpointer differs from int const *ourpointer?
What is the c++ programming language used for?
Is c++ high level programming language?
How can I learn c++ easily?
What is command line arguments in C++? What are its uses? Where we have to use this?