When I was in Yeshiva, a world renowned Posek* had a Q&A session with us, and the question came up regarding if you know that a teacher takes test questions from some online question bank if you're allowed to search them up and study directly from those questions. He answered emphatically yes.
If I recall correctly (it's been a few years since I heard it, and unfortunately the hard drive where I saved the recording is no longer with us), he said it was permitted even if the teacher explicitly told the kids not to look online for the answers. The Posek said that the teacher had no right to demand that kids not look up the answers; if it's out there, the kids have a right to look at it.
I believe this would apply to an actual copy of the test from previous years that a teacher 'released into the wild'. If the teacher let students keep the test, the teacher can't prevent students from sharing the test with future students. If the teacher collected the tests back and somehow a student got a copy of the test, then the students wouldn't be allowed to use the questions (this would be no different than stealing a test as per @ShmuelBrin's previous answer).
However, I would go so far as to say it would even be permitted, for example, for a student with photographic memory to memorize all the questions and write them all down afterward the test and share them with other students. While the students might not be allowed to have a physical copy of the original test if the teacher collected it back, the teacher can't prevent the information from being spread.
As an aside, the Posek somewhat tongue-in-cheek mentioned that he had no sympathy for teachers who don't make original tests, as he himself is a Halacha teacher in a Yeshiva and still takes the time to write original questions before each test. He said it only takes a few minutes, and if the teacher is too lazy to do that, the teacher can't expect the students to not search for the answers online.
*I apologize, but I have a rule where I don't post anyone's name online without their permission, unless it's something they published. You'll have to take the word of a random 1,300 point user for what it's worth...