Cisco interview question

How do a switch in layer 2 and 3 works?