If a player is standing inbounds but holds the ball out of bounds in the air, the ball is still considered to be inbounds.
If a player steps on any part of the boundary lines or crosses the sidelines and baselines in any way, they are 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. If it is impossible to tell, a jump ball will be used to put the ball back in play.
The only other boundary line on a basketball court is the circle surrounding a jump ball. No player who is not involved in the jump ball may cross the line until the ball has been hit.