Expression or cognitive error in assuming one person's fault on a community

Is there a term in psychology or English language to express the cognitive error in extrapolating one person's fault on the entire community?

Example:

A: Doctor A is arrested for unethical medical practices. B: All doctors are like that.

A: Teacher X works just for the money. B: No teacher is committed to their work.


Solution 1:

Formally,

  • a faulty generalization is a conclusion made about all or many instances of a phenomenon, that has been reached on the basis of one or a few instances of that phenomenon.

Informally,

  • a stereotype is an over-generalized belief about a particular category of people.