The scattering of surface and internal waves by a single dike or a pair of identical dikes in a two-layer fluid is analyzed in two dimensions within the context of linearized theory of water waves. The dikes are approximated as cylinders of rectangular geometry and are placed in a two-layer fluid of finite depth. In the study, both the cases of surface-piercing and bottom-standing dikes are considered. The solution of the associated boundary value problem is derived by a matched eigenfunction expansion method. Because of the flow discontinuity at the interface, the eigenfunctions involved have an integrable singularity at the interface and the orthonormal relation used in the present analysis is a generalization of the classical one corresponding to a single-layer fluid. The reflection coefficients and force amplitudes are computed and analyzed in various cases. The computed results in a two-layer fluid are compared with those existing in the literature for a single-layer fluid. The results obtained by the matched eigenfunction expansion method are compared with that of wide-spacing approximation method, and it is observed that the results from both the methods are in good agreement when the dikes are widely spaced. The general behavior of reflection coefficients for interface-piercing and non-interface-piercing obstacles is found to be different in both cases of surface-piercing and bottom-standing dikes. Moreover, for surface-piercing dikes, the results show the possibility of very large resonant motions between the dikes but with a very narrow bandwidth for the frequency of interest.