We perform a 2.5-dimensional particle-in-cell simulation of a quasi-parallel shock, using parameters for the Earth’s bow shock, to examine electron acceleration and heating due to magnetic reconnection. The shock transition region evolves from the ion-coupled reconnection dominant stage to the electron-only reconnection dominant stage, as time elapses. The electron temperature enhances locally in each reconnection site, and ion-scale magnetic islands generated by ion-coupled reconnection show the most significant enhancement of the electron temperature. The electron energy spectrum shows a power law, with a power-law index around 6. We perform electron trajectory tracing to understand how they are energized. Some electrons interact with multiple electron-only reconnection sties, and Fermi acceleration occurs during multiple reflections. Electrons trapped in ion-scale magnetic islands can be accelerated in another mechanism. Islands move in the shock transition region, and electrons can obtain larger energy from the in-plane electric field than the electric potential in those islands. These newly found energization mechanisms in magnetic islands in the shock can accelerate electrons to energies larger than the achievable energies by the conventional energization due to the parallel electric field and shock drift acceleration. This study based on the selected particle analysis indicates that the maximum energy in the nonthermal electrons is achieved through acceleration in ion-scale islands, and electron-only reconnection accounts for no more than half of the maximum energy, as the lifetime of sub-ion-scale islands produced by electron-only reconnection is several times shorter than that of ion-scale islands.