IANAL, but it is only illegal to discriminate against protected classes. It is legal to discriminate against people without college degrees or aren't attending college, just as it is legal to discriminate against smokers, or people who can't code.
Age over 40 is a protected class, and anti-discrimination law protects not only against facially or intentionally discriminatory acts, but also against those with a disparate impact not sufficiently justified by business concerns (though the standard for that is weaker for age discrimination than other workplace discrimination.)