PISCATAWAY, N.J. - Speaking at the Rutgers University commencement Sunday, President Obama condemned what he said was a disturbing anti-intellectual strain in contemporary politics and delivered a thinly disguised takedown of presumed Republican nominee Donald Trump.

"In politics and in life, ignorance is not a virtue," Obama told more than 50,000 people in Highpoint Solutions Stadium, home to the school's football program.

"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," Obama said, laughing. "That's just not knowing what you're talking about."

The president never mentioned Trump's name, but his target was clear. Repeatedly, Obama attacked disparaging comments about Muslims and immigrants and opposition to free-trade deals, all positions characteristic of the real estate developer's freewheeling campaign.

Obama's 44-minute speech, despite its barbs, was well-received, drawing cheers and laughter from the 10,500 graduates seated on the field, and from many of their guests in the stands, as well. Perhaps he felt comfortable mocking Trump and Republicans in front of a student body that he said "just might be America's most diverse." (Rutgers says 46.7 percent of its undergraduate and graduate students are members of minority groups.)

"It's so great to be able to see him speak today - I feel a special connection," said Michael Ganoot, the university's only graduate from Hawaii, President Obama's home state. Ganoot, 30, has often seen the first family vacationing near his home in Waipahu, on Oahu island. He is set to graduate from Rutgers Law School at Camden next week.

Obama did not let the students off the hook, telling them they have a responsibility to stick up for reason in public debate, to participate in politics, to vote even when they don't get the result they seek.

If they are frustrated by lack of progress on income inequality, Obama said, they bear some of the responsibility if they have not been involved in the process.

"The reason some of these things have not happened even though the majority of people have approved, it's really simple," Obama said. "It's because a huge chunk of Americans, especially young people, do not vote. Apathy has consequences."

Relaxed, calling himself "an old head," Obama was the first sitting president to speak at a Rutgers commencement, in the university's 250th year. He joked about a "grease truck" popular on campus for lunch, teased the students' generation for poor spelling and handwriting, and noted that his new honorary doctor of laws degree wouldn't stop his daughters from treating him as a parental ATM.

He told the graduates that they, as citizens, must bear some responsibility for learning and speaking up for the truth, and cautioned against reading or listening only to viewpoints with which they already agree.

"Ironically, the flood of information hasn't made us more discerning of the truth. It's just made us more confident of our ignorance," Obama said. When leaders are "not held accountable for repeating falsehoods and just making stuff up, while actual experts are dismissed as elitists, then we've got a problem," he said.

Obama took aim at Trump as the former reality TV star is wrapping up the GOP nomination and attempting to unite his party. In many ways, the campaign is a referendum on Obama's eight years in office, and the president seemed to want to try to weigh in, even as Hillary Clinton and Bernie Sanders continue to wrestle for the Democratic nomination to try to succeed him.

The pace of change on the planet is accelerating, he said, and the toughest challenges, such as climate change, cannot be solved in isolation.

"The world is more interconnected than ever, and building a wall won't change that," he said. "Building a wall won't build our economy or protect our country."

The flagship State University of New Jersey, Rutgers is the eighth-oldest school in the nation, founded as Queens College in 1766, a decade before the Declaration of Independence. Rutgers will mark its 250th anniversary in November.

Obama received an honorary doctor of laws degree, the second incumbent president to do so and first to accept it in person. President Franklin D. Roosevelt accepted his honorary sheepskin in a statement dictated by telephone during the 1933 commencement.

Gov. Christie, who ran unsuccessfully for the Republican presidential nomination before endorsing Trump, did not attend the commencement Sunday. But he had a good excuse: He was down the road watching his son, Andrew, play catcher for Princeton against Yale for the Ivy League baseball championship.

A potential political bonus: There was no chance of pictures of the governor with Obama. Images of Christie and Obama after Hurricane Sandy in 2012 haunted him during the GOP primaries.

Lt. Gov. Kim Guadagno represented the state government.

215-854-2718 @tomfitzgerald