The Dow and the S&P 500 rose in choppy trading on Tuesday as higher oil prices lifted energy shares, while the Nasdaq fell on weakness in tech.

Investors' mood picked up after Federal Reserve Chairman Ben Bernanke said the U.S. economy seemed to have enough momentum to avoid a double-dip recession, though this was offset by continuing concerns of the sovereign debt crisis in Europe.

Bernanke's comments suggest that things aren't as bad as they sometimes seem, said Marc Pado, U.S. market strategist at Cantor Fitzgerald & Co in San Francisco. The market, in general, believes that's true as well.

Exxon Mobil Corp rose 2.6 percent to $60.85 and gave the Dow its biggest boost. Exxon advanced along with U.S. crude oil futures, which rose almost 1 percent, or 68 cents, to $72.12 per barrel. The S&P energy sector <.GSPE> gained 1.1 percent.

Caterpillar Inc also bolstered the Dow after the heavy equipment maker affirmed its long-term profit goal. Caterpillar's stock gained 1.2 percent to $56.49.

The Dow Jones industrial average <.DJI> was up 66.36 points, or 0.68 percent, at 9,882.85. The Standard & Poor's 500 Index <.SPX> was up 5.08 points, or 0.48 percent, at 1,055.55. But the Nasdaq Composite Index <.IXIC> was down 11.55 points, or 0.53 percent, at 2,162.35.

Large-cap technology companies dragged the Nasdaq lower after Bank of America-Merrill Lynch cut price targets on several Internet stocks, citing uncertainty over earnings due to the dollar's gains against the euro since April. Inc fell 2 percent to $119.58.

Another weight on tech was Microsoft Corp , which lost 1.8 percent to $24.84 after the Dow component said it planned to make a private offering of senior notes in a move to repay short-term debt.

Investors remained anxious about debt levels in several euro-zone countries, as Portugal, Italy and Spain prepared to sell new bonds this week. It will be Spain's first sale since a credit rating downgrade.

Europe remains No. 1 on the list of obstacles facing the economy, said Charles Lieberman, chief investment officer of Advisors Capital Management in Paramus, New Jersey.

Investors don't have the confidence that Europe will be able to address its shortfalls, or that European growth can recover enough to help these economies.

The euro, used by investors in recent weeks as a barometer for euro-zone stability, gained 0.6 percent to $1.1986, a session high, a day after the currency hit its lowest level against the dollar since early 2006 the Dow and S&P extended gains as the euro rose.

Goldman Sachs Group Inc shed 1.7 percent to $136.32 after the banking company was subpoenaed by the commission probing the financial crisis.

McDonald's Corp , another Dow component, was up 1.6 percent at $67.80 after it reported a stronger-than-expected rise in global same-store sales in May.

(Reporting by Ryan Vlastelica; Editing by Jan Paschal)