Answer:
The sides are 3 and 7 cm long.
Explanation:
Let the lengths be x and x+4 cm, then
(x + 4)^3 - x^3 = 316
x^3 + 12x^2 + 48x + 64 - x^3 = 316
12x^2 + 48x + 64 - 316 = 0
12x^2 + 48x - 252 = 0
12(x^2 + 4x - 21) = 0
12(x + 7)(x - 3) = 0
x = -7, 3
So one cube has side of length 3 cm.
The other has side 3+4 = 7 cm.