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 implicit pointer in c++?
What are the various storage classes in C++?
What does h mean in maths?
What is the array and initializing arrays in c++?
When does a 'this' pointer get created?
What is implicit conversion/coercion in c++?
Explain the extern storage classes in c++.
What is the difference between C and CPP?
Is map ordered c++?
How would you find out if a linked-list is a cycle or not?
Which bit wise operator is suitable for putting on a particular bit in a number?
Can comments be longer than one line?
Define what is constructor?
What is prototype in c++ with example?
How much do c++ programmers make?