A joke sets up a chain of logic, and then subverts it in a surprising and delightful way; that's the punch line.
A good joke sets up a chain of logic.