It looks like the 42 refers to the area of the base. If so, then we multiply that with the height 6 to get 42*6 = 252
So the volume of this rectangular prism is 252 cubic cm.
It seems strange that your teacher wrote "volume (in cm)" instead of "volume (in cm^3)" or "volume (in cubic cm)". Saying just "cm" without the "cubic" part is incorrect as centimeters alone are a linear unit, not volumetric.