In what circumstances can 呢 be interchangeable with 吗？
吗 and 呢 are not interchangeable.

你是同学 means: &quot;you are a classmate&quot;
你是同学吗？ means: &quot;are you a classmate? &quot;
你同学 means: &quot;your classmate&quot;
你同学吗？ means: &quot;is (he/she) your classmate?&quot;
the final particle 吗 here denote 'interrogative' or 'inquisitive'. It short, it always turns a sentence into question form

~

你同学(呢)? depend on context, it can mean: 1. &quot;(where) is your classmate?&quot; or 2. &quot;(how about) your classmate?&quot;
the final particle 呢 here denote &quot;alternative questions, affirmative negative questions (as stated in  user60651's comment).

你是同学呢! is a different thing. The final particle 呢 in this sentence serve no interrogative function. Which mean it doesn't turn  &quot;你是同学&quot; into a question. It serves to emphasize the sentence itself and/or the speaker's emotion (e.g. annoyed, determine) with the tone itself