If any person elected to any office shall undertake to exercise the same or discharge the duties thereof without first having taken the oath of office or given bond as required by law, he shall be guilty of a misdemeanor, and, on conviction thereof, shall be fined not more than five hundred dollars, or imprisoned in the county jail not longer than one year, or both.