Java engineer interview puzzle