Need help with test quesiton......
Hi everyone! I hope everyone had a fun memorial day weekend.
Ive been studying for this Java Cert test and the testing software
that came with the book as a question that i really dont understand. Any help on clarifying this question would be great.
Which of the following are true about this variable declaration?
private static int i = 3;
a.) The value of i may not be changed after being assigned a value.
b.) i may only be update by a static method
c.) the value of i is shared among all instances of the class in which it was declared.
d.)i may only be accessed in within the class in which it was declared.
they say that the answer is c & d. But i dont understand how this is possible. d makes sense but c does not. I could see if one is thinking in terms of encapsulation than you would have a public get method that would be invoked to retrieve the value of a private field variable after an instance of the class is created. But to directly access a private field variable wouldnt that result in a compilation error?