With a class of quantum heat engines which consists of two-energy-eigenstate systems undergoing, respectively, quantum adiabatic processes and energy exchanges with heat baths at different stages of a cycle, we are able to clarify some important aspects of the second law of thermodynamics. The quantum heat engines also offer a practical way, as an alternative to Szilard's engine, to physically realize Maxwell's demon. While respecting the second law on the average, they are also capable of extracting more work from the heat baths than is otherwise possible in thermal equilibrium.