Obama slams Trump in speech: 'Ignorance is not a virtue'

President Barack Obama (L) reacts after receiving an honorary doctorate of laws from President of Rutgers University, Robert Barchi during the 250th anniversary commencement ceremony at Rutgers University on May 15, 2016 in New Brunswick, New Jersey.

WASHINGTON - US President Barack Obama on Sunday criticised the populist campaign of Republican presidential hopeful Donald Trump, decrying "anti-intellectualism" and noting that "ignorance is not a virtue."

Obama did not specifically name the brash New York real estate developer during his remarks at a university graduation ceremony in New Jersey, but it was clear he was referring to the candidate who is running on a slogan of "Make American Great Again!"

The Democrat told students not to pine for an American golden age of years past, saying, "The good old days were not all that good," as he pointed out problems with racial discrimination, poverty and lack of equality for women.

"The world is more interconnected than ever before and it is becoming more connected every day. Building walls won't change things," Obama said, an apparent jab at Trump's calls for a wall along the US-Mexico border to keep illegal immigrants out.

Obama noted that no wall could stop outbreaks of infectious diseases like Ebola and Zika, or help the United States remain competitive in a time of globalisation.

"Suggesting that we can build an endless wall along our borders and blame our challenges on immigrants, that does not just run counter to our history as the world melting pot," Obama said.

"It contradicts the evidence that our growth and our innovation and our dynamism has always been spurred by our ability to attract strivers from every corner of the globe." The US president also denounced politicians who hold themselves up as examples of straight-talkers but shun political correctness.

"In politics and in life, ignorance is not a virtue. It's not cool to not know what you're talking about," he said. "That's not challenging political correctness. That's just not knowing what you're talking about."

Obama was speaking to students at Rutgers University, about one hour from New York. He wore a red and black gown and received an honorary degree from the school.