A 2cm3 is 2cm * 2cm * 2cm (it is a cube).
The dimensions of the box are multiples of 2 cm, so the cubes fit nicely:
8 cm: 4 cubes (8cm/2cm) in the length
4 cm: 2 cubes (4cm/2cm) in the width
10 cm: 5 cubes (10cm/2cm) in the height
So, 4 * 2 * 5 = 40 cubes totally fill the box,