"Short of putting a wall around the school blocking every access to it, people could potentially wander in. But that does not mean the public have access to it," he said.
The lawyer cited sections of the school's rules which not only barred public from accessing areas of the school but also made classrooms out of bounds to students during break times.
The alleged incident took place in June last year when one student "boosted" another into a position to see into the upstairs class.
Mr Earwaker accepted the door was unlocked but said it was closed.
Crown prosecutor Dale Dufty conceded the argument that the classroom was a public place was a weak one.
However, he argued the staff and students should be considered as "the public", therefore making the charge valid.
An affidavit provided by the school's head acknowledged that though classrooms were technically out of bounds at lunch, students did go there to speak with teachers.
Mr Dufty said the school's policies and what happened in reality were "two different things".
During the incident, the student who allegedly caught the teacher in a compromising position said he was going to discuss a change of classes.
"The object [of the legislation] is to criminalise conduct in places where the community or public should be protected," Mr Dufty said.
The teacher was suspended by the school after the incident before resigning the following month.
The New Zealand Teachers Council confirmed the man had signed a voluntary undertaking not to teach, but had been suspended anyway.
Judge Russell Collins said he would reserve his decision and ordered continued suppression for the name of the defendant and the school.