Stocks rose on Thursday as investors held out hope the economic deterioration was receding and positive news boosted consumer and home builder shares.

Although an unexpected rise in initial jobless claims still pointed to uncertainty in the labor market, investors took solace from the final reading of first-quarter gross domestic product, which contracted less than thought.

For now the hope is that we are still likely to be coming out of the recession sometime in the third quarter, said Steve Goldman, market strategist at Weeden & Co in Greenwich, Connecticut.

The Dow Jones industrial average <.DJI> rose 41.56 points, or 0.50 percent, to 8,341.42. The Standard & Poor's 500 Index <.SPX> gained 5.94 points, or 0.66 percent, to 906.88. The Nasdaq Composite Index <.IXIC> added 17.46 points, or 0.97 percent, to 1,809.80.

Standouts included Bed Bath & Beyond Inc , which reported a surprise rise in quarterly profit as it cut costs to offset slumping demand. The retailer's shares jumped 9.6 percent to $31.10.

Shares of homebuilders rose after Lennar Corp posted a wider quarterly loss but saw an increase in new home sales and orders. Lennar was up 13.6 percent to $8.88, while the Dow index of homebuilders <.DJUSHB> gained 2.9 percent.

Another bright spot among retailers was J.C. Penney Co Inc , which rose 4.4 percent to $27.77 after JPMorgan Securities raised its rating to overweight from neutral.

In an appearance before the U.S. House of Representatives Oversight and Government Reform Committee, Federal Reserve Chairman Ben Bernanke pushed back hard against accusations the Fed threatened Bank of America Corp executives if they halted a merger with Merrill Lynch or pressured them to withhold bad news about Merrill. Bank of America shares fell 2.1 percent to $12.09.

The broad S&P 500 has bounced as much as 40 percent from March's 12-year low on hopes the economy was stabilizing, but jitters over the strength of a potential recovery have stalled the rally recently. The S&P 500 is up about 34 percent from the trough.

(Reporting by Leah Schnurr and Ellis Mnyandu; editing by Jeffrey Benkoe)