Anyone with an internet connection can easily find out, for example, how to add together two ints in Java. But if someone took an introductory Java course and couldn't do that at the end of it, then they don't deserve to pass because they've clearly not learned what they were supposed to. If they were actually trying to program something and had to look up basics like that every time they used them, they would be so slow as to be completely useless. Or consider someone with a more time-critical job like a surgeon - they can do specific research beforehand but some level of knowledge (surgical techniques, how to use their tools, anatomy, etc.) is simply going to have to be in their head at the moment they need it or their patient could die.
Also, phones and internet access don't just provide knowledge, they're a way to communicate with everyone else in the room. If you want to see if any particular person has actually learned the material, you obviously can't allow that.