Johnson & Johnson posted a 5 percent drop in second-quarter earnings, but profit and revenue beat analyst forecasts helped by surprisingly resilient pharmaceutical and consumer product sales.

Revenue took a hit from patent expirations on its drugs for schizophrenia and epilepsy, but sales of its blockbuster arthritis drug Remicade were better than expected. Analysts also cited the ability of the diversified healthcare giant, whose shares rose 0.7 percent, to contain costs.

They went through a cost-cutting exercise about a year and a half ago, and it's definitely helping them with their earnings to date, said Jan Wald, an analyst with Noble Financial Group. The surprise is more on the revenue side ... and that bodes well.

The New Brunswick, New Jersey-based company, whose products range from Band-Aids to complex biotechnology medicines, earned $3.21 billion, or $1.15 per share. That compared with $3.37 billion, or $1.18 per share, in the year-earlier period.

Analysts on average expected $1.11 per share, according to Reuters Estimates.

J&J's quarterly revenue fell 7.4 percent to $15.24 billion, but was $190 million higher than analysts expected.

Sales would have been 6 percentage points higher if not for the stronger dollar, which hurts the value of overseas sales. Some analysts had expected a worse toll from currency.

All in all it looks like a positive quarter, especially considering the economic environment, said Damien Conover, an analyst at Morningstar.

The company reaffirmed its full-year profit forecast of $4.45 to $4.55 per share, which excludes special items.

Sales of prescription drugs fell 13.3 percent to $5.5 billion, as patients opted for cheaper generic forms of J&J's Risperdal schizophrenia treatment and Topamax, an epilepsy pill that lost U.S. patent protection in recent months.

Topamax sales plunged 73 percent to $182 million, while Risperdal fell 66 percent to $239 million.

Even so, analysts said they had been girding for an even bigger decline in the pharmaceuticals business amid the erosion of Risperdal and Topamax sales.

The pharmaceutical business looked especially strong to us, Noble's Wald said. He pointed to Remicade, whose quarterly sales jumped 24 percent to $1.1 billion. Declines for Procrit and Eprex -- anemia drugs strapped with safety concerns -- were not as bad as feared, he said.

J&J said it will not provide requested data to U.S. regulators about the delayed blood thinner Xarelto until at least the fourth quarter. J&J is partnered with Germany's Bayer AG on Xarelto, a potential blockbuster.

Global sales of consumer products fell 4.5 percent to $3.85 billion, while sales of medical devices and diagnostics slipped 3.1 percent to $5.89 billion. Growing demand for the company's surgical products and orthopedics products was partly offset by lower sales of stents, tiny devices used to prop open coronary arteries that have been cleared of plaque.

Consumer sales were strong as well, which is promising because that's the closest thing to the general public that Johnson & Johnson has so that might say something about the economy, Wald said.

Sales and administrative costs, and research spending also came in below the expectations of JP Morgan analyst Michael Weinstein.

One potential hurdle for J&J going forward will be the impact of safety concerns over its Tylenol painkiller, said Morningstar's Conover. Last month a U.S. advisory panel called for greater restrictions on acetaminophen products such as Tylenol, citing the potential for acetaminophen to cause liver failure and even death when taken in excessive doses.

J&J shares rose 51 cents to $58.23 in morning trading on the New York Stock Exchange.

(Reporting by Ransdell Pierson and Lewis Krauskopf, additional reporting by Toni Clarke in Boston; Editing by Derek Caney and Matt Daily)