Suppose I have the setup:
TreeMap<Long,ClassA> derkMap = new TreeMap<Long,ClassA>();
derkMap.put(1L,new ClassA());
Note that ClassA has public void doSomething(), which when called will change the instance's state permanently (in what precise way is irrelevant to this question). Note that once doSomething() is called, ClassA has a public boolean hasItBeenCalled() which will return true; else it'll return false if doSomething() has not been called.
If I run the following sequence in my main method:
- (1) Pass derkMapinstance to constructor of someClassB(i.e. instantiate in my main methodClassB objectB = new ClassB(derkMap);).
- (2) Call derkMap.get(1L).doSomething();from main method.
- (3) Within the instance of ClassB(i.e.,objectB), tryderkMap.get(1L).hasItBeenCalled().
Will (3) return true or false?
 
     
     
    