Step 1: Define a cavity. A pulmonary cavity is a gas-filled space within an area of consolidation or a mass, formed when necrotic tissue is coughed out, leaving a thick-walled lucency.
Step 2: Apply this to each option. Staphylococcus aureus pneumonia is strongly necrotizing. It produces multiple cavities, pneumatoceles, and abscesses, especially in children, in post-influenza patients, and in intravenous drug users with septic emboli. So option B is a true cause of cavitation.
Step 3: Examine the tuberculosis option carefully. Cavitation in TB is a feature of post-primary (reactivation, secondary) tuberculosis, not primary tuberculosis. Primary TB usually gives a Ghon focus with hilar lymphadenopathy and rarely cavitates. The word primary makes option A wrong for cavitation.
Step 4: Rule out the rest. Pneumoconiosis (such as silicosis or coal worker disease) causes fibrotic nodules and, in progressive massive fibrosis, can cavitate occasionally, but it is not the classic single best answer here. Interstitial lung disease produces reticular shadowing, honeycombing, and fibrosis, not cavities.
The best answer is option B, Staphylococcal pneumonia.