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
Explain the difference between c & c++?
What is a c++ class?
Should a constructor be public or private?
How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?
Does a derived class inherit or doesn't inherit?
Can we distribute function templates and class templates in object libraries?
What is this pointer in c++?
What are the uses of typedef in a program?
How can I learn dev c++ programming?
Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .
Explain the auto storage classes in c++.
Difference between strdup and strcpy?
What is the difference between method overloading and method overriding in c++?
Write a program using merge () function to combine the elements of array x[ ] and y[ ] into array z[ ].
Can a function take variable length arguments, if yes, how?