Is it realistic to hide behind cars when there is gun fire?

If bullets are flying, hide behind anything you can find.

If you have to hid behind a car, make sure you put the engine block between you and the person firing the bullets.  The rest of the car may give you some protection but not very much.
There is a big difference between cover and concealment.  This is an important consideration if the bullets are flying.  Cover is something that will stop a bullet and conceals your position.  Concealment is something that you can hide behind, like a bush, but a bullet will fly right through it.