Previously, I asked about an incoming President-elect and his Cabinet. However, there's another situation where a new person takes office, in a much more abrupt manner.
In the case of death, resignation, or impeachment of the current President, what happens to their Cabinet (and other advice-and-consent positions)? Does their successor inherit the same Cabinet automatically, or does the new President have to re-appoint anyone they want to keep? And is there any precedent for the new President to immediately replace people with their own picks, or is it a more gradual transition (if at all)?