Is a professor allowed to ask me what grade I got in a previous class?
In the US, federal student privacy laws (FERPA) dictate that schools restrict access to student educational records, so that only those with a "legitimate educational interest" can access them. Most universities interpret this such that the student's academic advisor can automatically see their full transcripts in the student record system, but not every professor of every class the student takes.
However, just because access is not automatic, does not mean that it is not allowed. If a professor has a "legitimate educational interest" in a student record, then they may request access to that record. (For example, from the student's academic advisor.) "Legitimate educational interest" will be defined in the school's Student Records Policy and in their annual FERPA disclosure. For example:
A school official has a legitimate educational interest if the official requires the information for the purpose of fulfilling his official duties, including but not limited to:
- performing a task that is specified in his or her position description or contract agreement;
- performing a task related to a student’s education;
- performing a task related to the discipline of a student;
- providing a service or benefit relating to the student or student’s family, such as health care, counseling, job placement or financial aid;
- maintaining the safety and security of the campus; or
- participating in or conducting studies, evaluations, or assessments of educational programs.
Finally, as the student, you are permitted to disclose your student record to anyone you want. Someone with no educational interest in your record - e.g. your parent - could ask you questions about your educational records, and you would be free to disclose that information or not.
There are very few things, if any, that professors are prohibited from asking. Asking some things (e.g., sexual orientation or marital status) might get a professor in trouble if a complaint is raised and the professor lacks a good reason for asking for the information. While asking for and obtaining previous grades could lead to a FERPA violation (or some other misdeed), I doubt a department chair would ever reprimand a professor for asking.
Now for why the professor might be asking for the grade, sometimes it is easier to ask the student then use the online system or go through the department administrator. Most likely, they are asking about the grade as a potential conversation starter. The issues they want to talk about possibly depend on the grade you got. For example, asking a D student if topic X was covered probably does not make as much sense as asking an A student. Asking a C student if they understand topic X might provide more insight than asking an A student.
I would suggest you just tell them the grade. If you are really worried tell the professor you don't like discussing grades but would be happy to talk about the content of the course.
When I was taking a class that required a pre-requisite and our teacher asked for the grade we got in that class he was ultimately trying to gauge his students.
He wanted to gauge how well everyone in the class understood the previous material. Based on the grades we gave him became a deciding factor on whether or not he would briefly go over the previous material the first week of class or just jump right into the new material.
I don't know this teacher but typically teacher's like to get a feel for the students that are taking their class. If a teacher can gather a better overall understanding of the students in the class they could use that information to better teach their students.