The correct response is: when there is a chemical reaction between metals and nonmetals.
This typically refers to processes such as electrochemical reactions in batteries, where chemical energy is converted into electrical energy through redox reactions.