Strong sales of cancer drugs and a turnaround in its baby care business helped Johnson & Johnson's third-quarter earnings and revenue outpace estimates.

Here's how Johnson & Johnson reported compared with what Wall Street was expecting, based on a survey of analysts by Refinitiv:

Earnings per share: $2.05, adjusted, vs. $2.03 expected

Revenue: $20.3 billion vs. $20.05 billion expected

J&J reported third-quarter net income of $3.93 billion, or $1.44 per share, up from $3.76 billion, or $1.37 per share a year earlier. Excluding items, J&J earned $2.05 per share, above the $2.03 expected by analysts surveyed by Refinitiv.

Net sales rose 3.6 percent to $20.35 billion, surpassing expectations of $20.05 billion.

J&J's pharmaceuticals segment posted $10.35 billion in revenue, beating analysts' estimates of $10.02 billion. Medical device sales totaled $6.59 billion, missing expectations of $6.64 billion. The consumer business reported $3.42 billion in sales, above the $3.34 billion Wall Street anticipated.

Shares of J&J rose about 2 percent on Tuesday. They're now down about 2 percent this year.

"It was a strong quarter across all three of our segments of the business," J&J's chief financial officer Joe Wolk said Tuesday in an interview with CNBC's "Squawk Box."

J&J tweaked its full-year forecast to between $8.13 and $8.18 per share, up slightly from the previously guided $8.07 and $8.17 per share. Wall Street anticipates full-year earnings of $8.15 per share, according to Refinitiv. The company predicts revenue in the range of $81.0 billion to $81.4 billion. Analysts had expected $81.21 billion.

In the quarter, worldwide sales of cancer drug Darzalex reached $498 million, missing analysts' estimates of $538.7 million from Street Account.

Sales of Stelara, an immunotherapy treatment for plaque psoriasis, reached $1.31 billion, exceeding analysts' expectations of $911 million.

Earlier this month, J&J inked an agreement with Arrowhead Pharmaceuticals to develop its gene-silencing Hepatitis B treatment and take a minority stake in the company. The deal could potentially be worth more than $3.7 billion.

"Pharmaceuticals, I just can't say enough about that division for us," Wolk said. "It continues to just generate new products in a profound way that's transformational to the current state of care, and that's led the growth of our company for many quarters now."

The consumer business' increase in sales comes, in part, thanks to revamping its iconic baby care line. The company relaunched the line in August after losing ground to niche upstart brands and facing a 20 percent sales decline since 2011. In the quarter, U.S. baby care sales increased 20 percent to $120 million, up from $100 million in the same time last year.

J&J reformulated its products, cutting the number of ingredients in half, eliminating dyes and sulfates and replacing ingredients like mineral oil with coconut oil, Trisha Bonner, associate director of research & development at J&J Consumer, told CNBC in May. The company also redesigned packaging, adding pumps to many of its products to make it easier for parents to use while holding a baby.

"It's much more receptive to the needs of millennial moms and dads in terms of the formulation and packaging," Wolk said.

-CNBC's Meg Tirrell contributed to this report

WATCH: Sears was the Amazon of the 1930s. Here's where the retailer is today