A)
Non-static variables of the class are known as instance variables. For each instance of a class one separate copy of these variables is created and hence the name. Moreover, unless instance is created, they don’t come into existence physically i.e. memory is not allocated for them.
Ex:
class A
class A
{
int a;
int b;
}
->Instance variable contribute to the size of the object.
-> Instance variables are meant for representing individual object information.
Comments
Post a Comment