That’s the case for very specific places, but in general, tabearuki is considered 行儀の悪いこと, meaning bad manners, basically.
Take a look at this article, for example. Or this anectode. Or info from a language school. Or this quora answer. They all discuss how eating while walking is bad manners and can bring nuisance to the people around you, even in non crowded places. Of course this is not every Japanese person’s opinion! I’ve even seen people advocating for it.
I think it’s not such bad manner that you would be scolded by a stranger, perhaps by a Japanese partner or close friend, but it’s definetly not seen in good eyes in general.
In my experience, this is because they conduct yearly x-ray examinations to detect tuberculosis and other lung diseases. Shirts and bras interfere with the image, so they ask students to bring a plain shirt to wear during the examination. However, if there’s no other option, they may ask them to do the examination bare-chested. In my case, there was gender separation (not only in location but also in the time frame), but I can’t say the same for all schools or age groups. Japanese schools are known for having students change into sports clothing in the classroom without gender separation up to 3rd or 4th grade, so I wouldn’t be surprised if there are schools that don’t separate genders for medical examinations.