A person who knowingly intrudes himself into a public office to which he has not been elected or appointed, or a person who, having been a public officer, knowingly exercises 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 class 2 misdemeanor.