We've learned about the baselines and the sidelines. Together, these lines make up the boundary lines on a basketball court. A player is out of bounds on the court, when they step on or cross the boundary lines (baselines and end lines).
If a player steps on any part of the boundary lines or crosses the sidelines and baselines in any way, he is out of bounds. An inbounds pass for the other team at the spot of the infraction is the result of this turnover.
What happens when the ball rolls out-of-bounds while not being held by a player? In this case, the last team to touch the ball will lose possession. This rule also applies if the ball bounces or ricochets off of a player on the court. This is the call that is hardest for referees to make in real-time, so they will often go to the monitor to review who actually touched the ball last.
Once the ball has been brought over half court by the offensive team, the half court line then becomes the out of bounds barrier. If a player is to step on the line or dribble past it, then it is considered a backcourt violation and is a turnover to the other team.