Emerson interview question

How does a AND, OR and NAND gate operate?