[statement] + 乎?
不亦 + [adjective] + 乎?
[exclamation] + 乎!
乎 ends a classical question the way 吗 ends a modern one. In modern Chinese you meet it in quotations, above all the opening lines of the Analects, and in a handful of phrases that kept it.
不亦 + adjective + 乎 is a rhetorical question that asserts: "is it not…?" means "it certainly is". In the first line below, 说 is read yuè and means "pleased".
Modern Chinese turned 不亦乐乎 into a degree phrase after 得: doing something 得不亦乐乎 is doing it flat out, usually busy or playing.
After an interjection, 乎 marks a sigh rather than a question.
几乎, 似乎, 在乎, 合乎 and 出乎 contain a different 乎, one that works like "at" or "to" and asks nothing. Only a 乎 at the end of a sentence is the question particle.