Default [Q] What's the difference between a device OS, apps, and firmware

I've done some research but many sources seem to either use the terms interchangeably or as separate items. I figured no better place than get the info directly from xda users. So basically I am trying to figure out what the differences are between an android app, and android OS, and android firmware. Your explanation will be much appreciated.

Also while i'm here if anyone could tell me what the difference in unlocking a phone, rooting a phone, and flashing a phone is that would be great.

Thanks in advance!