what are static, constant and read-only

24th Jul 2016, 4:33 AM
Shah Alam
Shah Alam - avatar
2 Answers
+ 1
think of them like holding unchanging. values the different is const need to initialize when we define it .and so the others
24th Jul 2016, 10:02 AM
Abdalrhman Shazally Abdalrhman Alhassan
Abdalrhman Shazally Abdalrhman Alhassan - avatar
static: Think, you have class name called bank account, your account number is constant, ur account balance is static.. where ever (in different instances of bank account class)u check the account balance it will be same.. static variables hold the same value irrespective of the instances of the class.. constant variables should be defined with the value while creating it.. read only variables can be accessed/retrieved the values using the class instances .. but other than the same class where it had been defined we cannot set the the values for the read only variables. please correct me if I am wrong..
24th Jul 2016, 7:31 AM
Duraichi Veerakumar