Unlike the caste system in India, in which caste is rigidly determined by birth, in China there was no inheritance per se. The sons of officials had to earn the post and thus the wealth their fathers had had, via the scholastic examination system. This system was theoretically open to everyone, including peasants. Many mandarins were peasants’ sons.
Of course, when China was occupied by the Manchus, Manchu birth was favoured at all levels, but the examination system functioned as it had for two thousand years, except during the brief era of Mongol rule.