Every person who wilfully and knowingly intrudes himself into any public office to which he has not been elected or appointed, and every person who, having been an executive, administrative or ministerial officer, wilfully exercises any of the functions of his office after his term has expired, and a successor has been elected or appointed and has qualified, is guilty of a misdemeanor.