The idea is that a joke works by making a logical connection but one that is unexpected. For a joke to work it must make sense.
I didn't mention facts. I was talking about beliefs. You wrote, " if you're in a pub with a mate, saying it quietly, not offending anyone, and you don't mean it, it's just a joke isn't it."
With "and you don't mean it" what exactly are you saying?
How can you "mean it" or not if the joke doesn't contain some sort of belief?
But then when I read the "jokes" you posted they're not that kind of joke. In both there is a character who you consider "other," a black man and an Indian, but neither joke is based on that. Both are based more on a logical trick. In the second one though you'd have to kind of agree that "living next to an Indian" is not a desirable situation. I guess the joke is "Indians prefer white people to Indians." I mean, LOL, right?
That's just kind of stupid. And the one about the "black man who drives a bus" sounds more suited to a playground than a pub.
But to the question, can you tell one of those jokes without being a racist? Possibly, but I think you would have to be a dimwit. They're just not funny.
The real question is "Can a racist joke be funny?" I think the answer to that is yes. But to decide a person "is" "a racist" is a very different thing. Can a person perform racist actions in some situations and not it others? Yes. Can you tell some stupid joke "at the pub" and not actually be stupid? Possibly, but at that moment in time in that situation you would be.