Page 1207 - AP Computer Science A, 7th edition
P. 1207

9. (B) A static variable is shared by all instances of the class. “Static” means that there will be just one memory slot allocated, no matter how many Insects are constructed. All instances of Insect access the same information stored in that slot. When an Insect is created, it will get tagged with the current value of nextAvailableID for that memory slot, which will then be incremented for the next Insect created. All of the ot her v ariables —age, idNum, position, direction—are specific to one instance of Insect and should therefore be private instance variables in the class.


































































































   1205   1206   1207   1208   1209