As 2020 comes to a close, it's time for investors to start thinking about the year to come. Unfortunately, with the coronavirus pandemic still a big problem for the U.S. and the world, there remains lots of uncertainty ahead. There's no guarantee that the economy will be out of its slump next year; in fact, we could be due for a long, deep recession.

To combat this possibility, investors may want to look at a couple of healthcare stocks that should be solid investments to hang on to through a recession. Both Johnson & Johnson (NYSE:JNJ) and Becton, Dickinson (NYSE:BDX) are long-term buys that can keep your portfolio safe during an economic slowdown. Here's why these are especially great choices if you're worried that things won't get much better next year.

1. Johnson & Johnson

Although Johnson & Johnson continues to face its share of legal problems, with lawsuits relating to opioids, baby powder, and more, it's still, generally speaking, a trusted, well-known brand around the world that continues to generate strong sales numbers. 

From $74.3 billion in sales in 2014, the New Jersey-based company's top line grew to $82.1 billion in 2019, averaging a compounded annual growth rate (CAGR) of 2% during those years. Even more impressively, in all but one of those years, its profit margin has been 18% or better.

Red arrow going down with dollar bill in the background.

Image source: Getty Images.

Even during 2020, a disastrous year as a result of the coronavirus pandemic, the company is still generating consistent results. Through the first nine months of the year, Johnson & Johnson's product sales of $60.1 billion are down just 2% from the same period last year. Much of this is thanks to its diverse business lines, which help the company adapt to changing situations. A year ago, medical devices made up more than 31% of the company's sales. However, in 2020, as hospitals are deferring procedures, medical device sales are down more than 15% and that segment now accounts for just 16% of Johnson & Johnson's revenue.

That's OK, though, because the company also makes pharmaceuticals, and sales of those are rising as people stock up during the coronavirus. This year, pharmaceutical sales account for 35% of Johnson & Johnson's total sales -- last year, they were just 18% -- and they've grown more than 5% thus far in 2020.

Johnson & Johnson is involved in the coronavirus vaccine race, too; its potential vaccine is currently in phase 3 trials. This is further proof of the versatility and adaptability that are so crucial in helping the company get through tough economic conditions. 

Finally, one more great reason to buy shares of Johnson & Johnson is because the stock's dividend yield is 2.8% -- well above the typical S&P 500 stock, which normally pays about 2%. In fact, the company is a Dividend King, having raised its payouts for more than 50 years in a row.

2. Becton, Dickinson

Another solid New Jersey-based healthcare stock to put in your portfolio for next year, Becton, Dickinson has been growing its sales over the years at an even higher rate than Johnson & Johnson. For fiscal 2019, the company reported sales of $17.3 billion, more than double fiscal 2014's tally of $8.4 billion. That averages out to a CAGR of more than 15%. Becton, Dickinson's profit margin, however, has been a bit more modest during that time, coming in at less than 10% in each of the past five fiscal years. 

In fourth-quarter earnings released Nov. 5, quarterly sales totaled $4.8 billion, up 4.4%. Although revenue in its medical and interventional segments was down by 4.9% and 3.4%, respectively, the life sciences division grew at a rate of more than 31%. Much of this is thanks to diagnostics, where revenue of $807 million was double that of last year.

In the earnings release, the company pointed to its COVID-19 testing platforms, including BD Veritor and BD Max, as key to its strong sales numbers in the fourth quarter. Becton, Dickinson estimates that by March of next year, it will be able to produce 12 million SARS-CoV-2 antigen tests every month, up from 8 million right now.

As with Johnson & Johnson, the recurring theme for Becton, Dickinson is diversification. By having a broad mix of divisions that can generate sales growth for the business, the company is able to adapt to different economic conditions. While medical delivery revenue may be down this year, testing is up. And once concerns surrounding the coronavirus pandemic start to subside and things get back to normal, the reverse may be true.

That stability makes its dividend attractive. Today, Becton, Dickinson pays investors a quarterly dividend of $0.79, which yields a modest 1.3% annually. The company has increased its dividend payments for 48 years in a row, and two more rate hikes would put it in the category of a Dividend King.

Both stocks are great buys if you're worried about a long recession

During the last recession (highlighted in grey on the chart below), both of these stocks did better than the S&P 500:

JNJ Chart

JNJ data by YCharts

There's little reason to believe much would change during another recession. During the crash earlier this year, both stocks suffered lighter losses than the index:

BDX Chart

BDX data by YCharts

If you're looking for a solid long-term investment to hang on to during a recession, either one of these stocks could be a great option to put in your portfolio today. If you're looking to maximize your dividend income, Johnson & Johnson and its higher payout may be more appropriate. But if you're concerned about that company's legal headaches, then Becton, Dickinson could be the more appealing healthcare investment for your risk profile.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.