Though he didn't name Trump, Obama's target was apparent.
"In politics and in life, ignorance is not a virtue," he told the more than 12,000 graduates in New Brunswick, New Jersey. "It's not cool to not know what you're talking about. That's not keeping it real or telling it like it is. That's not challenging political correctness. That's just not knowing what you're talking about. And yet we've become confused about this."
Obama's comments at Rutgers echo similar shots he's taken at Trump -- also without naming him -- during recent appearances.
The President also told the graduates to stand up to those who say that America was better in the past and dismissed the idea of building walls.
"I guess it's part of human nature -- especially in times of change and uncertainty -- to want to look backwards and long for some imaginary past when everything worked, and the economy hummed and all politicians were wise and every child was well-mannered and America pretty much did whatever it wanted around the world," Obama said. "Guess what? It ain't so. The good old days weren't all that good."
He also challenged the notion that Muslims should be banned from the United States, something Trump proposed in December.
"Isolating or disparaging Muslims, suggesting that they should be treated differently when it comes to entering this country, that is not just a betrayal of our values. That's not just a betrayal of who we are -- it would alienate the very communities at home and abroad who are our most important partners in the fight against extremism," the President said.
Obama is the first sitting president to speak at Rutgers University, which had lobbied for the last three years to get him to speak at the commencement.
Last week, Obama spoke at Howard University's commencement address in Washington. On June 2, Obama will continue his yearly tradition of addressing graduates of a U.S. military service academy, this time at the Air Force Academy in Colorado Springs.