In ancient(古代的)China, people have three names: their family name, given name, and courtesy name(字). Take famous poet Li Bai as an example, his family name is Li, his given name is Bai, and his courtesy name is Taibai.
People use their given names when they are with their family or friends. And your elders like your grandparents and parents call your given name at home. But in the workplace, people use their courtesy names.
Men get their courtesy names when they are 20 years old. Women get their courtesy names after they get married(结婚).
People's courtesy names have something to do with their given names. For example, Zhuge Liang's given name is Liang. It means "bright". His courtesy name is Kongming. And the meaning is "very bright".