Can a Shimano 7-speed cassette been used on a 9 or 10-speed bike?
With a few spacers in place as needed, you can certainly use an HG-pattern Shimano cassette on an 8/9/10-speed Shimano-type cassette hub*. For a whole bike, though, unless you swap over to 7sp indexed kit throughout or use down tube levers set to "friction", you might run into problems where the rear mech's concerned. Also, a 9 or 10 speed chain will probably be too narrow to run a 7 speed cassette.
*My touring bike has a modern Sunrace 7sp cassette on an 8sp Sachs New Success hub plus a spacer to ensure it all fitted OK.
"Not so much a religion as a savings club for people who think Star Trek's a documentary"
- Marcus Brigstocke on Scientology