Consider the following application:
1. public class Main { 2. public static void main(String args[]) { 3. Holder h = new Holder(); 4. h.myInt = 100; //from ww w. j a v a2 s . com 5. h.bump(h); 6. System.out.println(h.myInt); 7. } 8. } 9. 10. class Holder { 11. public int myInt; 12. public void bump(Holder h) { 13. h.myInt++; 14. } 15. }
What value is printed out at line 6?
D.
A holder is constructed on line 3.
A reference to that holder is passed into method bump()
on line 5.
Within the method call, the holder's myInt
variable is bumped from 100 to 101.