A common objection asks why questioning occurs if Allah already knows every act and intention. It assumes that the only purpose of a question is to discover an unknown fact. Questions may also elicit acknowledgment, disclose truth, establish responsibility, or make a judgment evident.
Divine knowledge: eternal, complete, and prior to all questioning.
Final questioning: a real confrontation of a person with actions and accountability.
There is therefore no contradiction unless questioning is first redefined as necessarily providing new knowledge to Allah, which is not the claim.