Interesting question! The basic answer is no, there is no difference in basic engineering quality within a brand line these days. The same technology and materials is used in Corolla as a Camry. The same materials are used in gaskets, seals, castings and stampings. A corolla engine will certainly last as long as even a Lexus engine. The only differences may be found in things like aluminum suspension pieces vs stamped steel in the cheaper car. There are anecdotally just as many Corollas driving around with 300,000 miles as Camry’s and Lexus; same for Honda Civics and Accords and Acuras.
Overall, most of the differences are things you can see, like the interior, performance, ride and handling, amount of sound deadening, etc. There is a lot less profit in entry level cars than upmarket.