let's recall that the volume of a rectangular prism is simply the product of its 3 dimensions.
so the volume for the first one is simply 3*4*8 = 96.
now, let's do some quick prime factoring of that 96
96 = 2*2*2*2*2*3
since we know the factors of 96, and we can rearrange them in any way we wish and will always have a product of 96, well, le'ts do some rearranging for the second prism.
the second prism has 4 and 4, namely 2*2 and 2*2, what's leftover? 2*3.
so the second prism must be (2*2) * (2*2) * (2*3), namely a 4x4x6.