A joke sets up a chain of logic, and then subverts it in a surprising and delightful way; that's the punch line.
A joke is generally defined as following no chain of logic and ending in a predictable way.