Japanese people care a lot about social status and rank and this is reflected in the language in many ways. One of the most basic and most important is in the use of honourifics—the short suffixes on the end of names meant to show respect and recognize status, akin to the English Sir or Mrs.
Photo by Terri Oda
San (さん) is used when addressing nearly anyone. It's like Mr or Mrs, but it isn't gender specific. It shows respect and indicates a nearly equal social status between the speaker and listener (although actually the listener is a bit higher).
While it's the norm to use san for last names, like Tanaka-san or Suzuki-san, non-Japanese often get it attached to their first names. The simple reason is that people don't understand which name is the first and which is the last. If you introduce yourself as John, you'll get stuck with John-san.
San isn't used for people you know really well. It's also not generally used for people within your group. For example, although you refer to co-workers as san, you may drop it when talking to people outside your office. It's not usually used for members of your own family but always used for members of another person's family.
Kun and Chan
Kun (君) and chan (ちゃん) are cutesy honourifics used mostly for children. Boys go with kun and girls with chan. They're terms of affection. While they're always used for kids, they're sometimes used for young adults or family members.
It still feels weird to me to call a grown adult kun or chan, especially if they're older than me, but if someone introduces themselves that way, you should use it. Men sometimes go by chan among their close friends. I think of it as something like 'Bobby' instead of 'Bob' to make it less weird for me to refer to adults that way.
Sama (様) is a term used to show higher status. This is a term used for kings, gods, customers and exalted celebrities who are in every way better than we mere mortals.
It can also be used sarcastically:
Haruka-sama ga ooki ni narimashita
Her Royal Highness Haruka has woken up.
Omae, nani-sama da to omou?
Who the %#$)! Do you think you are?
Use it this way at your own risk and don't tell anybody I taught it to you.
Senpai and Kohai
In school or work settings, honourifics are attached to names to show rank. Senpai (先輩) indicates someone that is your senior. Kōhai (後輩) indicates a younger student or employee. These may also be used in informal settings or among friends to indicate age or rank.
Shi (氏) is used in formal writing like news stories. It's a more formal version of san. It's not used much in everyday conversation.
Occupation words are also used as suffixes. People that hold a special position in a company, such as the shachō (社長 – president), will get the title attached. Teachers and doctors get a sensei (先生) attached. Athletes, singers, writers and so on get honourifics attached.
As a rule of thumb, call everybody san unless they ask you to call them something else.