The Dow Jones industrial average rose 38.29 points, or 0.28 percent, to end at 13,649.97. The Standard & Poor's 500 Index was up 1.41 points, or 0.09 percent, at 1,531.85. The Nasdaq Composite Index was up 3.51 points, or 0.13 percent, at 2,670.02.
J&J gained 1 percent after the health-care company announced plans for a $10 billion share buyback. ConocoPhillips, which nearly quadrupled its repurchase plan to $15 billon, rose 3.7 percent.
Alcoa gained 1.7 percent and was a top performer among the Dow industrials. The aluminum producer kicked off the second-quarter earnings season after the bell, reporting a profit that matched estimates.
"The market is holding up to the summer doldrums pretty well," said Tom Schrader, managing director of U.S. equity trading at Stifel Nicolaus Capital Markets in Baltimore.
"Generally people are anticipating earnings are going to come out a little bit better than expected," he said.
Alcoa ended the regular session at $42.36, up 1.7 percent, or 70 cents, on the New York Stock Exchange.
Current projections put second-quarter earnings growth at 5.6 percent over the year-ago period, according to Reuters Estimates. The number is based on forecasts for S&P 500 companies from Wall Street strategists and industry analysts.
Shares of Johnson & Johnson gained 1 percent to close at $62.72 on the NYSE.
ConocoPhillips shares rose 3.71 percent, or $3.01, to finish at $84.05 on the NYSE and hit a fresh lifetime high of $84.73 earlier in the day, after it said it plans to buy back up to $15 billion of its shares through the end of 2008, nearly quadrupling its previous repurchase plan.
Boeing (BA) was among the companies that led the Dow industrials' advance, with a 1 percent gain to $99.90 on the NYSE, a day after it unveiled its 787 Dreamliner passenger jet.
Positive brokers' comments on Google Inc. (GOOG) pushed the Internet company's shares up 0.6 percent, boosting the Nasdaq. Google shares closed at $542.56 on the Nasdaq after theflyonthewall.com reported that Think Equity, a brokerage, had raised its price target on the stock to $700 from $620. Earlier, Google hit a lifetime high of $548.74 on Nasdaq.
Shares of FedEx Corp. (FDX) rose 4.8 percent to $116.17 on the NYSE after Barron's, the weekly financial newspaper, said the package delivery company may become a takeover target, while Paccar Inc., the No. 2 U.S. maker of heavy trucks, jumped 5.3 percent to $93.50 on the Nasdaq after Bear Stearns raised its rating on the stock.
Trading was moderate on the NYSE, with about 1.34 billion shares changing hands, below last year's estimated daily average of 1.84 billion,. On the Nasdaq, about 1.90 billion shares traded, below last year's daily average of 2.02 billion.
Advancing stocks outnumbered declining ones by a ratio of about 6 to 5 on the NYSE, while on the Nasdaq, decliners beat advancers by about 16 to 15.