Solution:
The order of basicity is I > III > I> IV
The lone pair of electrons on N is more readily available for protonation in I and III then in II. IlI contains an oxygen atom which has — I effect due to which it is less basic than I. In compound IV lone pair of e-s on N—atom is contributed towards the aromatic sextet formation and hence is not at all available for protonation. Hence option (2) is correct.