Stocks gained on Wednesday as results from banks including Morgan Stanley and Wells Fargo topped expectations, and on increased optimism about the profit outlook for the technology sector.

Financial shares led the way, with Morgan Stanley jumping 6.7 percent to $34.71 after it posted a profit after three quarters of losses on strong fixed income sales and trading revenues.

Wells Fargo & Co and U.S. Bancorp results were boosted by revenue from underwriting mortgages, but the windfall could moderate as applications fall. Wells rose 0.7 percent to $30.71, while U.S. Bancorp gained 1.7 percent to $19.11. The KBW banks index <.BKX> rose 1.1 percent.

Although the robust results cheered the market, analysts raised concerns over how sustainable these types of profits would be in the long term.

Back in March, the banks were priced as though they were going out of business, and in fact many people thought that, said John Canally, investment strategist and economist for LPL Financial in Boston.

We've rallied out of the idea that they're not going out of business, and now it becomes more how are you running your business?

The Dow Jones industrial average <.DJI> rose 51.32 points, or 0.51 percent, to 10,092.80. The Standard & Poor's 500 Index <.SPX> gained 7.55 points, or 0.69 percent, to 1,098.61. The Nasdaq Composite Index <.IXIC> put on 19.04 points, or 0.88 percent, to 2,182.51.

The Dow's gains were limited as Boeing Co shed 1 percent to $51.40 after the airplane maker posted a net loss on charges related to its long-delayed 787 plane and the 747 program.

Technology shares also bolstered the market on increased optimism about the sector's profitability.

Yahoo Inc climbed 4.4 percent to $17.93 the day after it beat profit and sales expectations and said advertising showed signs of life last quarter.

Apple Inc hit a record intraday high of $205.80. Google Inc was up 1.3 percent at $558.88.

(Editing by Jeffrey Benkoe)