If I buy a Mac that was shipped before Mavericks was released, will it have Mavericks preinstalled?
Solution 1:
Mavericks is free so just install from App Store
Solution 2:
Update: The info below is still valid for past practices but Apple yesterday released Mavericks and announced that it is free to download through the Mac App Store. New Macs shipping today will still more than likely have Mavericks pre-installed, but if you do end up in a situation where a Mac you ordered a few days ago ships with Mountain Lion installed you can simply upgrade by installing Mavericks from the Mac App Store at no charge.
In the past Apple has included "drop in" upgrade DVDs with new Macs that shipped prior to the official release of the new OS. This means that for a month or so after Snow Leopard was released you were likely to buy a new Mac that booted to Leopard but had a Snow Leopard disc tucked away in the box.
Once the new OS' went to a download only method Apple switched to an "up to date" program, where you could submit the Mac's serial number to a webpage and receive a redemption code to download the new OS from the Mac App Store. The same time frame of "about a month" seemed to hold true with this last new release.
Obviously I can't say with 100% certainty that this will be the case with Mavericks but I would be surprised if any significant changes were made.
The up to date webpage is no longer active but this MacRumors article has a screenshot from when around the time it launched.
Source - I worked at Apple, at an Apple Authorized Reseller and have received Macs in bulk for my current job, all at times when Apple launched new operating systems.