Was James Potter a Head Boy when he was at Hogwarts?
I don’t think you *have* to be a prefect to be head boy. James was definitely head boy, and Hagrid said he wasn’t a prefect, so we have to assume that to be the case. Also, remember that James’ behaviour was pretty cheeky and arrogant for a while, and then he changed a bit and grew up and became a better student (and won Lily’s heart). So I think perhaps he wasn’t mature enough to be prefect when he was younger, but by the time he was in his 7th Year, he’d become a more exemplary student, had grown up a bit, and was rewarded for that with the Head Boy position.