Warren Buffett, the man widely considered the greatest investor of all time, is a champion of long-term investing. It's no surprise then to see a number of attractive holdings that have passed through the portfolio of the company he leads, Berkshire Hathaway. For investors looking for inspiration, it's a good idea to peek at Berkshire's holdings occasionally.

Let's look at two positions -- one current and one former -- that have made it into Buffett's portfolio at various times and are worth considering today: Johnson & Johnson (JNJ -0.46%) and Apple (AAPL -0.35%).

1. Johnson & Johnson

Johnson & Johnson has already passed the test of time. The healthcare giant has been around for over 100 years. While it's no longer in Buffett's portfolio, the drugmaker still has many of the qualities that allowed it to succeed in the past.

First, it has been incredibly picky with its leaders. Johnson & Johnson has had seven CEOs since it became a publicly traded company in 1944. A corporation's leadership team is one of the most important factors for its success. The drugmaker has always made sure to select qualified leaders who have generally served for a long time. The current CEO, Joaquin Duato, officially took that post in January 2022.

Second, J&J is a highly innovative company. It continues to develop newer and better medicines and medical devices. Johnson & Johnson's pharmaceutical pipeline includes 94 ongoing programs, some of which are brand-new therapies. These often lead to new approvals, such as that of Akeega, a cancer medicine that hit the shelves for the first time this year.

Johnson & Johnson's late-stage pipeline includes such products as potential stroke prevention medicine milvexian, and AAV-RPGR, a potential gene therapy for a rare eye disease. With the company having recently spun off its consumer health unit, it plans to dedicate even more funds to research and development in its pharmaceutical and medical device units, which should pay off down the line.

Third, Johnson & Johnson has deep footprints in the healthcare industry, which is highly regulated and challenging to navigate. Those factors, and others, should allow the company to remain in business -- and perform relatively well -- for many more years.

Of course, investors can't ignore J&J's incredible dividend track record. The company has now raised its payouts for 61 consecutive years as part of the elite club of Dividend Kings. There aren't that many better income stocks on the market, whether investors want passive income on the side or to boost their returns over long periods by opting to reinvest their dividends.

Johnson & Johnson's current dividend yield of 3.07% is notably higher than the S&P 500's average of 1.62%, while its cash payout of 75% looks a little high but should be manageable. Johnson & Johnson has had its share of legal issues, which, in my view, the company will be able to handle. Over the long run, the drugmaker is still in an excellent position to deliver stability, solid returns, and competitive dividends.

There's no way to know for certain, but perhaps these legal troubles partly explain why Berkshire Hathaway recently shed its position in the healthcare stock. However, Berkshire has bought and sold the stock on several occasions before. Buffett has generally focused on the sectors he knows best, and healthcare stocks have never been a large part of his company's portfolio.

Still, due to its solid position in an industry that won't die out anytime soon, not to mention its amazing dividend program, Johnson & Johnson remains a top pick for long-term investors.

2. Apple

Apple has been one of Buffett's favorite stocks for a while. The tech giant accounts for a large percentage of Berkshire Hathaway's portfolio. Several factors make Apple such an outstanding stock for long-term investors. Despite selling electronic devices that aren't necessary items and have plenty of substitutes, Apple has made itself hard to replace.

Besides the company's strong brand name and high customer loyalty, Apple has a thing for adding its ingenious spin on existing technologies, starting new trends, and drawing customers in. In addition, it offers a set of perks to those who use its devices, including a range of entertainment services, many of which they would have to give up if they decided to drop Apple. In other words, the company benefits from high switching costs.

Apple's large installed base of more than 2 billion devices is arguably where its most lucrative long-term opportunities lie. The company will increasingly seek to come up with new and improved ways to monetize its customer base -- the possibilities here are practically endless. Apple is dabbling in healthcare, fintech, and several other areas.

Further, Apple is also an excellent dividend stock. Though it isn't a Dividend King, it has raised its payouts by 120% in the past 10 years. Apple also has a great track record of improving its revenue, earnings, and cash flow.

AAPL Revenue (Quarterly) Chart

AAPL Revenue (Quarterly) data by YCharts

While the iPhone no longer generates the attention it once did, it is still the company's biggest earner while it continues to expand its high-margin services segment. Apple seems to have some of the tools necessary to succeed in the next 10 years and beyond.

A solid economic moat, multiple growth paths, and the ability to generate plenty of free cash flow to reinvest into its business. In short, investors can safely park this tech stock in their portfolios for good.