The power can be added to the ethernet cable if the switch has a built-in power source in the form of PSE is called Endspan Equipment, as shown below: -
Alternatively the power can be added to the cable after the switch by using a PSE called Midspan Equipment, as show below: -