Federal Reserve Chairman Ben Bernanke told law school graduates on Friday that the recession-mired U.S. economy would recover and to remain optimistic about their job prospects.

Things usually have a way of working out, he said in remarks prepared for delivery to the Boston College School of Law.

The labor market is weak and economic conditions are trying, but the Fed is aiming to restore stability and foster growth, he said.

Restoring economic prosperity and maximizing economic opportunity are the central focus of our efforts at the Fed, he added.

Bernanke told students to disregard pessimistic commentary about the future of the U.S. economy and its role in the world.

The economy will recover -- it has too many fundamental strengths to be kept down for too long -- and the mood will brighten, he said.

Bernanke offered wisdom from references to Bank of England Governor Mervyn King (the object of central banks should be to make monetary policy as boring as possible), scientist Louis Pasteur (Chance favors the prepared mind), and Beatle John Lennon (Life is what happens to you while you are busy making other plans).

The Fed chairman made fun of himself, telling students that he spoke a year earlier to a graduating class to which Harry Potter author J.K. Rowling also delivered an address. The student who introduced Bernanke jokingly described the two speakers as two of the great masters of children's fantasy fiction, he said.

(Reporting by Mark Felsenthal; Editing by Andrea Ricci)