For a company to survive for decades is a feat in and of itself. For that company to also thrive, year in and year out, is rare. If your goal is to buy a stock and hold it forever, passing it down to your children and their children, you need to invest in a company that can stand the test of time.

There are no guarantees in the world of investing, but if you're looking for some family heirloom stocks, look no further than Canadian National Railway (NYSE:CNI), Coca-Cola (NYSE:KO), and Johnson & Johnson (NYSE:JNJ).

A close-up of a stock certificate.

Image source: Getty Images.

Give your grandkids a toy train and Canadian National Railway stock

Tyler Crowe (Canadian National Railway): If you want the kind of stock that you can hand down through generations of your family, is there a better one than railroad company Canadian National Railway? The railroad industry itself has immense competitive advantages that other forms of transportation simply can't overcome. The cost of moving heavy goods over long distances via rail have consistently been a fraction of what it costs to move goods by any other means. So, until we build some sort of teleportation device, rail will continue to dominate the transportation industry as the lowest-cost way to get products from one point to another.

What separates Canadian National from the rest of the railroad stocks, though, is the way in which it operates. Simple things like keeping yard time down, locomotive utilization rates high, and gross tons moved per train high help to keep operational costs low. Maintaining operational excellence in these areas is why Canadian National has remained at the top of the list of rail companies in terms of returns on equity over the past two decades.

CNI Return on Equity (TTM) Chart

CNI Return on Equity (TTM) data by YCharts.

It's hard to find a business built to stand the test of time more than railroads, and it's even harder to find a railroad stock more worthy of owning for generations than Canadian National Railway. 

A century-old beverage giant

Tim Green (The Coca-Cola Company): There are plenty of reasons to dislike Coca-Cola stock as an investment. Soda consumption is declining, with 2016 marking the 11th consecutive year of slumping carbonated soft drink sales. Diet sodas were among the worst performers, with consumers growing weary of artificial sweeteners.

There's no guarantee Coca-Cola will remain a great company if and when it emerges from its current slump, but that's true of any company facing challenges. Coca-Cola has been around for 130 years, with its stock no doubt passed from generation to generation. If you had to bet on a company to survive the next 130 years, Coca-Cola wouldn't be a bad choice.

Coca-Cola will need to adapt to changing consumer tastes, and a lumbering, century-old company will always take longer to do so than investors would like. Warren Buffett's Berkshire Hathaway is still a major shareholder, owning nearly 10% of the company. A strong brand and an unparalleled global distribution network are what Buffett cares about, not temporary issues. Don't expect Coca-Cola to beat the market in the short term, but the company should be around long after today's high-flyers are just memories.

A healthcare stock for all seasons

Cory Renauer (Johnson & Johnson): Investors looking for an heirloom stock that can weather inevitable economic downturns should consider shares of the world's largest healthcare company. Some of the iconic brands in its consumer division date back to the 19th century -- and they still provide a rock-steady source of high margin revenue.

While you're most likely familiar with Q-tips, Listerine, and Band-Aids, you might not realize that Johnson & Johnson is a conglomerate that operates over 250 subsidiaries that fall into three main segments: consumer goods, medical devices, and pharmaceuticals. While familiar, over-the-counter medications such as Tylenol push consumer sales higher, you probably haven't heard of Biosense Webster brand pacemakers. This business has grown sales at a double-digit percentage during 28 of the past 29 quarters. That's the sort of performance you like to see from a company you intend to hold forever.

The consumer and medical device segments still contribute a majority of Johnson & Johnson's total revenue, but new prescription drugs will provide the most lift in the years ahead. In 2016, pharmaceutical sales rose 6.5% to $33.5 billion, and this could be another banner year for the segment. Last year, its blood cancer treating tablet, Imbruvica, became the first chemotherapy-free treatment option for the most common form of leukemia. Sales of the drug bounded up 82% in 2016 to $1.25 billion, and the treatment could eventually contribute about $6 billion to J&J's top line each year.

Further out, a handful of recently launched drugs and some that are nearly ready for an FDA review lead me to believe that J&J's best years are still to come. You can reasonably expect the stock to maintain an upward trajectory and lengthen its 54-year long streak of annual dividend payment raises well into the years ahead. 

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.