When the ball is heated, it expands and becomes bigger in diameter than ring and it cannot pass through the ring. When the ball is left to cool on the ring for some time, it again passes through the ring. This is because on cooling, the ball contracts.