When the jar is accelerated forward, the cork's inertia will ten to keep it at rest, thus it shift to the back of the jar. If the jar is accelerated to a slower speed, the cork's inertia will tend to keep moving, thus it will shift to the front of the jar.
When moving the jar in a circle, the cork's inertia will tend to keep the cork moving in a straight line, thus it shifts to the outside of the jar (directly away from the center).
When there is water in the jar the cork floats. All the the previous obervations will be opposite. The reason is that the water has more inertia then the cork and its inertial will result in the cork being displaced by the water. Thus, for example, as the jar is accelerated forward, the water tends to shift to the back of the jar, leaving the cork in the front of the jar.