johnny
2011-12-02 15:49:26 UTC
VendingMachine vend2 = new VendingMachine();
vend2.reset();
vend2.addCandy("Milky Way", 0.50);
System.out.println(vend2.totalItems);
1. The code tries to access a private instance variable.
2. The code tries to modify a static variable.
3. The code tries to modify a private instance variable.
4. There is nothing wrong with the code.
I've got this from the book. I've already picked #4 but which is wrong. I don't really see any errors. and I don't think its number 1 unless we suppose to assume they've already set to private?
can anyone help pick the right answer and explain? thanks!