Capital gain refers to the increase in the value of a capital asset. This can be anything like a stock, real estate, a piece of art, and so on. On the other hand, if the value of the asset declines and it is sold at a price lower than the purchase price, it refers to capital loss. Capital loss from investments can be set off against capital gains to arrive at the net gains for taxation. The rules for this vary.
Companies prefer to keep most of their net profits, called retained earnings, that are used for growth, expansion, and future business activities. A part of the net profit is distributed among the shareholders as their reward for investing their money and acquiring shares of the company. This is called dividend. Dividends may be given out once a year or quarterly when the results are announced. Dividend income and capital gains may be taxed at different rates.
In the question, an investment is made in Walmart stock, and the purchase price is $100. The stock is sold after a year at $125.73. The investor also receives $5 as dividend. Here, the difference in the sale price and the purchase price is $25.73. This is the capital gain. The $5 received as dividend is the dividend income.