0

What is the difference between static and constant

31st Oct 2016, 4:01 PM
Manje Gowda K R
Manje Gowda K R - avatar
6 Respuestas
+ 4
static variables are shared variables between objects of same class. it has common memory. constant variables are variables with fixed value which cannot be changed. but in case of static variables value can be changed but it cannot be reinitiallialized ( means address cannot be changed)
31st Oct 2016, 4:12 PM
Samkitkumar Jain
Samkitkumar Jain - avatar
+ 3
normal variables are not constant Thier value can be changed & they can also be reinitiallialized
31st Oct 2016, 4:15 PM
Samkitkumar Jain
Samkitkumar Jain - avatar
+ 1
An static property can be changed freely during the program execution. A constant has its value defined at the beginning of the execution and can never change its value.
31st Oct 2016, 4:10 PM
Lucas Araujo
Lucas Araujo - avatar
+ 1
Then how it is different from variable?
31st Oct 2016, 4:14 PM
Manje Gowda K R
Manje Gowda K R - avatar
+ 1
What is the difference b/w Static and variable ?
31st Oct 2016, 4:17 PM
Manje Gowda K R
Manje Gowda K R - avatar
+ 1
static variables are stored in data segment, thus they are global throughout the program. whereas const variables are stored in the stack (if locally declared) otherwise in the data segment
27th Dec 2016, 5:51 PM
Suvaditya
Suvaditya - avatar