This can be solved using the combination formula C(n,r), where n is the number of objects ( lockers) and r is the sample ( number of students).
There are 7 lockers and 4 students, so it would be written as C(7,4)
= 7! / (4!(7-4)!)
= 7*6*5*4*3*2 / ((4*3*2)*(3*2))
=5040 / (24*6)
=5040/144
=35
There are 35 different ways.