Lets we have following declaration.
char c = ‘A’;
string s = “STR”;
Then values of variable c & s will get stored in memory, in following way…..
00001
|
A
|
00002
|
00003
|
00003
|
S
|
00004
|
T
|
00005
|
R
|
Table: Memory Status
·
Definition 1: Data types,
which are stores its value directly at their own memory location; those data
types are called as “Value” type.
·
Definition 2: Data types,
which are stores address (pointer/reference) of its value at their own memory
location, those data types are called as “Reference”
type.
From above memory status we can do following statements
·
Statement 1: Address 00001 represent variable c & it containing
value ‘A’.
·
Statement 2: Address 00002 represents variable s & it contains
value 00003, which is nothing but starting address
of value ‘STR’.
From Definition 1 & Statement 1 we would say that char is Value type
&
From Definition 2 & Statement 2 we would say that string is Reference
type
No comments:
Post a Comment