Reciprocating follow-up questions
The most common use of 呢 is bouncing a question back: A says 我很好 (I am good) and B says 你呢 (and you?). Here 呢 carries the meaning "what about you / how about you", avoiding the need to repeat the full question. You can attach 呢 to any noun or pronoun: 他呢 (what about him?), 这个呢 (what about this one?), 明天呢 (what about tomorrow?). 吗 cannot do this; a 吗 question needs the full verb and subject.
A: 我喜欢咖啡,你呢? B: 我喜欢茶。
A: Wǒ xǐhuān kāfēi, nǐ ne? B: Wǒ xǐhuān chá.
A: I like coffee, and you? B: I like tea.
呢 with question words
呢 softens questions that already use question words: 他是谁呢 (so who is he?), 你去哪儿呢 (where are you going?). The 呢 makes the question feel more curious, thoughtful, or engaged, rather than abrupt. 吗 never pairs with these because 吗 is for yes-no questions. Mix-up warning: 他是谁吗 is wrong; use 他是谁 or 他是谁呢.
这件事怎么办呢?
Zhè jiàn shì zěnme bàn ne?
What should we do about this?
呢 emphasizing ongoing action
呢 at the end of a sentence with 在 or 正在 emphasizes that an action is happening right now: 他在看书呢 (he is reading right now), 我正在吃饭呢 (I am eating right now). The 呢 adds the feeling of "this is what is going on, FYI". Without 呢 the sentence still works but loses the "right now" punch. 吗 cannot perform this function; it stays a pure question marker.
A: 他在干什么? B: 他在玩游戏呢。
A: Tā zài gànshénme? B: Tā zài wán yóuxì ne.
A: What is he doing? B: He is playing a game.
呢 as a mild pause or thinking particle
In some contexts, 呢 marks a pause for thought or softens a statement: 这个嘛, 我想想看呢 (this... let me think about it). It is like English "well" or "you see" or "hmm, let me think". This is advanced usage; for HSK purposes, focus on the reciprocating question and the progressive-emphasis uses first.
Summary table
吗 = yes-no question marker (only). 呢 = reciprocating question ("what about X"), softener on non-yes-no questions, emphasizer on ongoing action, and occasional pause. They overlap zero; choose based on what you need. If the question expects yes or no, use 吗. If it expects anything else, use 呢 or just the question word.