For the hypotenuses to be able to lie on the same line:
The tan of angle in both should be the same. That is the two triangles should be similar.
For the first triangle tanθ = 4/10 = 2/5
For the second triangle, tanθ = 12/30 = 6/15 = 2/5
Since both angles in the triangle are the same, hence, the hypotenuses of the two triangles could lie along the same line.