Basicity is determined by the electron-donating or withdrawing effects of substituents on the aniline ring. Methoxy groups are electron-donating, so Compound B is the most basic. The nitro group is electron-withdrawing, making Compound A the least basic. Chlorine is weakly electron-withdrawing, so Compound D is less basic than Compound B, and Compound C is less basic than B but more basic than A.