My dad’s a philosopher and has been quizzed on philosophy by border guards before. And while I haven’t gotten the full-on quiz treatment, I usually get something along the lines of “why are you going to [location?]” “Study abroad.” “Oh, what are you studying?” “Math.” “What kind of math?” “Number theory and combinatorics.” “Cool; have a great day!”
My dad, like me, is about as white as you can get (something like sixth-generation Irish-German Americans), so I’m not at all convinced this is a race thing. I was under the impression it was pretty common, when entering under a visa for a specific purpose, to be asked a couple of pseudo-small-talk questions about it to see if you have suspicious trouble answering or are otherwise Acting Oddly, and occasionally given a more thorough quiz.
Honestly, this seems like a pretty reasonable way of doing something that isn’t racial profiling, while still letting the guards feel like they are Doing Something (and possibly even Actually Doing Something, who knows); someone who’s traveling legitimately won’t have a problem answering “what is an abstract class” or “name a major work of Kant” or the equivalent for their work visa, while someone who isn’t will be lost.
(Of course, you’re going to get some false positives. My dad is amazingly bad at this sort of screening. Once they asked him ‘where are you coming from’ and he couldn’t decide whether to say ‘the US’ or ‘Texas’ and stood there contemplating for an extended period of time. The guards, reasonably enough, found this somewhat suspicious, and he got a pretty extensive grilling before they let him go through.)