Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is difference between static and non-static variables

Answers were Sorted based on User's Feedback



what is difference between static and non-static variables..

Answer / sv

static variable retains its value like a global variable,
but visible with in the scope.
While non static variable will not be retained one it come
out of the scope or block. Again the visibility is local to
the block.

Is This Answer Correct ?    53 Yes 8 No

what is difference between static and non-static variables..

Answer / udit rawat

static variable take memory first at linking and loading time
while non static variable take memory at compile time

Is This Answer Correct ?    35 Yes 11 No

what is difference between static and non-static variables..

Answer / 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

what is difference between static and non-static variables..

Answer / sengar

static variable will not be change value all time but non
static value can be changed according requirement .
without giving any value static variable automatically
initialize by zero but in non-static case not the same
case.

Is This Answer Correct ?    11 Yes 2 No

what is difference between static and non-static variables..

Answer / daxini

Static :
A static variable is defined for the class itself and exists independently of any object of that class.
non-static:
a non static variable is defined for object of the class thus it is bound to an instance of its class

Is This Answer Correct ?    10 Yes 2 No

what is difference between static and non-static variables..

Answer / r

veryb good answer

Is This Answer Correct ?    6 Yes 1 No

what is difference between static and non-static variables..

Answer / narender vadhava

static variables have their fix values within a program but
in case of non-static variables their values are changable
within the same program.
syntax of static variable:-
static int s;
while
non static variables declared only by using general basic
data type.
as:-
int s;

Is This Answer Correct ?    14 Yes 12 No

what is difference between static and non-static variables..

Answer / arun kumar

Initialization of static variables is at compile time,
but in case of non-static variables is at run time.

Is This Answer Correct ?    6 Yes 7 No

what is difference between static and non-static variables..

Answer / basharat ali

satatic variable use any where but non-static variable can
use with in a block..............

Is This Answer Correct ?    2 Yes 6 No

what is difference between static and non-static variables..

Answer / achal ubbott

The above answers are correct. A local static variable is
stored in heap. But a local variable is stored onto stack.

A Global variable made static can't be accessed from a
function outside the file using extern. So it limits the
scope.

Is This Answer Correct ?    2 Yes 10 No

Post New Answer

More C++ General Interview Questions

Is facebook written in c++?

0 Answers  


What is encapsulation in c++ with example?

0 Answers  


Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02

0 Answers  


What is meant by iomanip in c++?

0 Answers  


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

0 Answers  


What are advantages of c++?

0 Answers  


What do you mean by friend class & friend function in c++?

0 Answers  


How can you create a virtual copy constructor?

0 Answers  


What are destructors?

0 Answers  


Write a program to encrypt the data in a way that inputs a four digit number and replace each digit by (the sum of that digit plus 7) modulus 10. Then sweep the first digit with the third, second digit with the fourth and print the encrypted number.

0 Answers   CIIT Wah,


What is size of a object of following class? class Foo { public: void foo(){} }

2 Answers   CA,


What is wrapper class in c++?

0 Answers  


Categories