If I were a Spanish Major as an undergraduate and decide to pursue a PhD in a completely unrelated field (like Theoretical Physics), it makes sense to give a qualifying exam to check that I had the necessary skills to begin the program. But if I'm coming from a B.S in math to a PhD program also in math, it doesn't seem to make sense to give a qualifying exam, as if the knowledge I gained in my undergraduate was insufficient. I presume that one is accepted into a PhD program because he/she has already demonstrated the "qualifying" skills. Thus, I'm baffled by the notion of the qualifying / prelim exam. I'm curious about the ultimate goals of these exams, and how they relate to the professional development of a graduate student.
This answer serves mainly to corroborate @Anonymous Mathematician's answer.
As she says, the most important thing to realize is that there are two different kinds of exams that go under the name "prelims / quals". The first of these generally:
(i) tests undergraduate material
(ii) is administered soon after arrival in the graduate program
(iii) used to be used for preliminary weed-out purposes but is now -- at least, in most programs I know about -- used almost entirely for diagnostic purposes.
Probably (iii) is most important: once upon a time, many graduate programs -- even excellent ones, like Berkeley (in fact, especially Berkeley) -- admitted lots of students, as in up to 50% more than were expected to finish. The idea was to give a large group of people, including those with less than sterling (or ivy) pedigrees, a fair shot. Then after a small amount of time in the program -- maybe a year or less -- they would take a "prelim" exam, and a significant portion would fail and leave.
This is no longer the way graduate programs work (at least not in North America, which is what I am primarily familiar with, but to the best of my meager knowledge they don't work that way in other parts of the world either). We pay much closer attention to each student we admit now than in the scenario above, and further our program is judged on retention and completion rates. A graduate program in 2012 who dismissed a third or more of its incoming class every year would look disastrously bad by these sorts of metrics. So this "weedout prelim" is, as far as I know, a thing of the past.
In the graduate program at UGA we still give a "prelim exam" to all entering graduate students, but as I said above we use it almost entirely for diagnostic purposes. In fact we have a certain graduate course designed entirely for students who didn't do well on the prelim, whose purpose is to shore up their undergraduate knowledge ASAP. Other than being encouraged to take this course, there are no direct consequences of failing the prelim (in fact, I'm not sure that one "passes" or "fails" the prelim in any technical sense).
In contrast, most of the "qualifying exams" that you hear graduate students talking about are something entirely different. They:
(i) test graduate level material; in particular, most students do not enter equipped with the knowledge to pass most qualifying exams.
(ii) occupy students' attention for a while: in our program, students have up to three years to pass their qualifying exams.
(iii) really must be passed in order for students to advance in the program, in most cases.
I hope this answers your question. Let me say though that the scores on the "prelim" exam -- i.e., the undergraduate level exam that I mentioned first -- are often all over the place. All of our entering students have at least an undergraduate degree in mathematics. So, unfortunately, no, an undergraduate degree in mathematics is not a guarantee of ability to do undergraduate level mathematics...at least not to the satisfaction of a decent mathematics graduate program. (And a student who does poorly on this entering prelim may yet succeed in doing PhD level mathematics a little later on: that is, the fault often seems to lie with the undergraduate program more than the student.)
There are two types of qualifying/preliminary exams, those that cover graduate or undergraduate topics. I assume you are just talking about the latter (while in my experience the former is a little more common).
As I see it, the big reason for preliminary exams on undergraduate material is that many students haven't actually mastered this material to a professional standard. At less prestigious schools, many students won't have received straight A's (or the equivalent in other grading systems), so they had gaps or weaknesses in their understanding, and unless they took more advanced courses in the same area they may never have filled those gaps. Furthermore, it's possible to get excellent grades without true mastery, and students sometimes forget things they knew while taking a course.
The preliminary exam sends a message of "OK, you're in grad school now, and as a professional you're expected to know this material cold. If you have any doubts about your mastery of it, now is the time to study carefully." The few students who don't need to study suffer little harm from the exams, and the students who do need to study benefit from the studying.
There are two main reasons:
- as a "sanity check" to make sure that the student you've admitted is really the student you thought they were; and
- as a weed-out tool, in case you've admitted more students than you have spots for in PhD projects in a given department.
Both purposes are significant. The second is the more unfortunate, and could generally be reduced through better selection processes and through better deployment of teaching and research resources and funding within a department. The former use is equally important, in that it makes sure that students don't try to "coast" their way through what the department believes is its core curriculum that students need to know.
I concur with @Pete L. Clark and @Anonymous Mathematiciar. These exams have names that suggest the darker purposes in their pasts, but they are mainly used as administrative tools by graduate departments.
At the graduate school I attended for chemistry, we took "placement exams". These exams happen for three reasons:
1) to provide the department with a common baseline, as we all did not likely take exactly the same GRE on exactly the same day. Particularly, this provided a means to directly compare the national students with the foreign students.
2) to identify deficiencies, as @Pete L. Clark and @Anonymous Mathematiciar have indicated. In chemistry, the smaller schools occasionally cannot offer courses in all five disciplines: organic, inorganic, analytical, physical, and biochemistry. Rather than punish those students for attending small liberal arts schools, many Ph.D. programs accept them on the premise that they may have to take an undergraduate course to fill in the gaps.
3) to select TAs. All first year graduate students in my chemistry program had to TA undergraduate labs. The placement exams determined which course you got to TA. The highest scorers on the organic chemistry exam were TAs for organic chemistry labs. The highest scorers on the analytic chemistry exam were TAs for analytical chemistry labs, and so on.