There are C(29, 4) = 29!/(4! (29 - 4)!) ways of selecting any 4 students from the total 21 + 8 = 29 students.
The teacher has C(21, 2) = 21!/(2! (21 - 2)!) ways of picking out 2 sophomores and C(8, 2) = 8!/(2! (8 - 2)!) ways of picking out 2 freshmen, so there are
C(21, 2) • C(8, 2) = 5880
possible ways of picking out 2 sophomore and 2 freshmen.
The probability of picking out a group of students like this is then
C(21, 2) • C(8, 2) / C(29, 4) = 280/1131 ≈ 0.2476