+ 1
What is the value of a instance variable when we have 2 objects.
As we can create multiple objects in a class and they can have diffrent instance variable values. Let there are two objects dog and cat of class animal. There is a instance variable declared String animalsound; I use these methods to set its value. cat.setSound (meww meww); dog.setSound (woof woof); So what is the value of animalsound variable after applying these methods.
1 Resposta
+ 1
Before creating the object this class is like a blueprint. You can create any number of object of this class. Right!!! So if you a set a property to a particular object then that property can be accessed only by that object . An instance value can't exist alone. And if you access this member variable directly it will pop up an error.