Pneumonia refers to inflammation of the lung tissue. This inflammation of lung tissue could be due to numerous causes, both infectious and non-infectious. Important infectious causes of pneumonia are viruses, bacteria and fungi. Pneumonia can also be caused by chemical injury (a non-infectious cause).
There is no simple answer to this question. Pneumonia can be both, contagious and non-contagious depending upon the cause of pneumonia. Moreover, the contagious causes of pneumonia are not contagious throughout the course of illness, but only during a certain period. A bacterial pneumonia is less likely to be contagious after taking antibiotics for few days. The pneumonias caused by bacteria and viruses are usually contagious, where as those caused by fungus and chemicals are not contagious.
Pneumonia can also be caused by chemical injury to the lung tissue. This may occur due to inhalation of toxic fumes or gases (for e.g. in a fire or industrial accident). Similar chemical pneumonitis might also occur because of aspiration of gastric contents (including gastric acid) in persons with altered level of consciousness (coma patient, excessively drunk persons, etc.). These pneumonias are not contagious unless there is also a superimposed viral or bacterial infection after the initial chemical injury. So is pneumonia contagious? It depends.
Mere exposure to a person with "contagious" pneumonia is not enough to cause pneumonia. Although exposure is important, it is not the only factor determining the development of pneumonia. It is quite common that the exposed person may not develop pneumonia, or develop only a mild respiratory tract infection.
The immune status and lung condition (any preexisting lung disease) of the exposed person is particularly important in this regard. Moreover, even different normal persons have different susceptibility to different infectious agents. Same infectious agent may cause different spectrum of illness in two individuals. Most commonly, a person exposed to "contagious" pneumonia, will either have no symptoms or develop only a mild respiratory tract infection. Developing pneumonia is rare unless the person has compromised immune system or suffering from preexisting heart/lung disease.
Is pneumonia contagious? It varies in different condition. Immune status and predisposing conditions (if any) in the affected person are also important in determining whether the pneumonia would be contagious or non-contagious. People with immunosuppression due to any cause (chemotherapy, transplant, AIDS, etc.) might even develop pneumonia due to certain less virulent infectious agents. Such less virulent pathogens fail to cause clinically significant pneumonia in normal healthy individuals. Therefore, although an infectious pneumonia, this pneumonia might not be contagious. Similarly, preexisting heart and lung diseases might also predispose to developing similar non-contagious infectious pneumonia. It is important to note that such persons might have contagious pneumonia also.