Oxygen (O2) Sensor Info:
3rd generation rams have 4 total O2 sensors (Exception: 2003 dodge rams are the red headed step child, then only have 2). They are located in the driver and passenger exhaust manifold.
2 upstream, and 2 downstream. The upstream ones are right after the header (or in the tail end of the header if you have long tubes, while the downstream ones are located aft of the catylitic converter (CAT).
The upstream O2 sensors help determine, in real time, if the air/fuel ratio of the engine is rich or lean. Now since they are in the exhaust, they do not directly measure the air or the fuel entering the engine. But when information from sensors is added with information from other sources, it can be used to indirectly determine the air-to-fuel ratio.
They downstream sensors will only read your catylitic converter efficiency, and thus are only really for emissions. They will shoot a fail code if your cat fails or you install a high flow cat, or delete the cat entirely.
There are also two different types of O2 sensors. Heated and unheated.
The unheated sensors only last about 50K miles, and require 1-3 minutes to heat up to operating temperature. They only have two wires coming from them.
The heated terminals last up to 100K miles, and differ in that they contain 4 wires. 2 of the wires are for the heating element which heats the sensor up fast so it can work properly without waiting for the exhaust to heat up.
What does this mean for you:
Ok so when you start your vehicle, your ECU regulates your air/fuel ratio based on a preset 14.7/1 air to fuel ratio. There's no inputs or changes, it stays the same. This is called an open loop.
When your o2 sensors heat up and start sensing the oxygen levels in your exhaust, the information is added to other sensors, sent to your ECU and converted into data to regulate your Air/Fuel ratio. Things like elevation, temperature and air density can change the way your engine runs, so this information is vitally important. When all these sensors are working together and the information is being sent to your vehicles computer, it's called a closed loop. If you start your vehicle and listen to the engine, you can usually hear when it changes from an open to closed loop. It happens pretty quick if you have a newer vehicle.
How can they go bad: Now these sensors are directly in the path of your exhaust... so eventually they will go bad. Sometimes the heating element will fail, or the sensor will get clogged (especially if your running rich), which will be noticeable because the sensor will be black with thick soot.
If you install long tube headers, or high flow catalytic converters, or remove the cats, the sensors will show an increase in exhaust and oxygen and thus give you a fail code. You can install spark plug non-foulers to help this (they fit between the exhaust manifold and the sensor). These will move your O2 sensor out of the direct path of the exhaust so they wont read a failing cat.
If you only have 2 sensors (2nd gen rams and older vehicles) the sensor fail code will read Bank 1 Sensor 1 (front sensor), or Bank 1 Sensor 2 (aft sensor).
If you have 4 sensors, Bank 1 is the passenger side exhaust/header pipe, and bank 2 is the drivers side exhaust/header pipe.
So Bank 1 Sensor 1 (Passenger side front sensor), Bank 1 Sensor 2 (Passenger side aft sensor, Bank 2 Sensor 1 (Driver side front sensor), Bank 2 Sensor 2 (Driver side aft sensor).
If you do end up throwing a code, refer to this site for the type of error your receiving:
OBD-II Check Engine Light Trouble Codes