Oj is a catch-all exclamation for expressing these feelings, used when something surprising or unexpected happens (Read also: Ten ways speaking Swedish will ruin your English).
It's very efficient: if you bump into someone, no need for a long and wordy apology, a heartfelt oj! will do and they'll understand it wasn't intentional. If someone bumps into you, an oj with a slightly different tone and a frown is a way of reprimanding them – whether your oj is positive or negative is entirely context dependent.
In other circumstances, it might be a pleasantly surprised “wow”, a sympathetic “oh dear”, or a neutral “oh!” or “well!”. All of this makes it a useful word for Swedish-learners to use; simply slip it into conversation whenever the occasion presents itself for a handy shortcut to fluency. And if something really surprising happens, try several in a row: oj oj oj oj oj – this is a sound you'll hear a lot during sports matches.
There's also the more emphatic ojdå! which again can be positive or negative. And the verb 'att oja sig' literally translates as “to oj oneself about”, and can be used when someone is complaining or going on about something.
Ojdå, något gick fel
Oh dear, something [unclear or unexpected] went wrong (a typical computer error message)
Oj, vad synd!
Oh, what a shame!
Det är inget att oja sig över
It's nothing to make a fuss about