Wall Street closes higher as buyers consider the future for megacaps and earnings.

On Tuesday, U.S. stocks concluded the trading session on a positive note, buoyed by encouraging earnings reports from prominent companies, while investors awaited quarterly updates from major corporations, including what are sometimes referred to as the "Magnificent Seven" and other megacap growth stocks.

Tesla (TSLA.O) set the stage for the technology sector's earnings cycle by announcing the introduction of new electric vehicle models and reporting quarterly revenue, which fell short of analyst estimates. Nevertheless, its shares surged by 6% during after-hours trading.

Positive earnings from companies such as General Motors (GM.N), which exceeded quarterly expectations, also contributed to market optimism. General Motors' stock closed up 4.4% following the announcement of its better-than-expected results.

Most sectors within the S&P 500 saw gains, with notable advances in communication services and technology sectors, although the S&P Materials sector ended lower due to steelmaker Nucor Corp's (NUE.N) disappointing first-quarter earnings, causing an 8.9% decline in its stock price.

Keith Lerner, co-chief investment officer at Truist Advisory Services in Atlanta, attributed the market's positive momentum to a continuation of the previous day's rebound and renewed focus on strong earnings reports across various sectors.

In terms of indices, the Dow Jones Industrial Average rose by 263.71 points (0.69%) to 38,503.69, the S&P 500 gained 59.95 points (1.20%) to 5,070.55, and the Nasdaq Composite increased by 245.34 points (1.59%) to 15,696.64.

Economic data released on Tuesday indicated a cooling of U.S. business activity in April to a four-month low due to weaker demand, alongside a slight easing of inflation rates despite sharp rises in input prices, potentially signaling relief ahead for consumer prices.

Stocks such as Spotify (SPOT.N), GE Aerospace (GE.N), and Danaher (DHR.N) experienced notable gains after reporting positive earnings or bullish forecasts. Conversely, JetBlue (JBLU.O) saw its shares plummet nearly 19% as the airline reduced its annual revenue forecast following lukewarm first-quarter revenue.