When is a door not a door? When it’s ajar. This riddle plays upon the similarity in pronunciation between the word "ajar," meaning partly open, and the phrase "a jar," meaning a broad-mouthed container.
This riddle is an example of a pun. A pun is a type of joke that derives its humor from the use of a single word which has multiple meanings, or the use of two or more words that are alike or nearly alike in sound, but have different meanings. The use of puns can be traced back as far as the 7th Century BC where they appeared in Sanskrit Literature.