I am in the process of adding new pex segments and I have this question:when you are adding new pipes segments to existing lines and they are capped at the end(ex copper stub outs)? what happens with the air trapped there? does it get pushed out if I open the taps to adjacent sink (next room) or upstairs (bathroom)
These dead ends will immediately or eventually fill with water. How fast this happens depends on their orientation and whether water can pour in and air can escape back into the main branch and escape through a different fixture.
Sometimes air can remain trapped for a long time if the dead ends are pointed upward.
A closed off upward column of a foot or two is used in plumbing to absorb water pressure hammering.
When a nearby fixture rapidly closes (e.g. a solenoid valve in a washing machine), the water comes to an abrupt requiring a place for the kinetic energy to go, and the water would "ram" or hammer into the valve thus forming a water hammer. The hard hammering can be softened by providing an air cushion in the form of an air filled standing pipe with a dead end as a shock absorber.
However, it turns out that the air and water do mix over time, and the the length of the air column shortens in that upright closed pipe, eventually rendering this kind of water hammer arrester ineffective.
Today plumbers will install a spring or membrane based water hammer arrester. The membrane based absorber operates on the same principle as the dead end stand pipe, allowing a pocket of air and the elasticity of the membrane to absorb the shock. The membrane maintains the integrity of the air pocket by preventing the mixing of water with air.