The formula for calculating gravitational potential energy is expressed as
GPE = mgh
where
m represents the mass of the object
g = acceleration due to gravity = 9.8 m/s^2
h is the height of the object
Let mass of ball B be m and height of ball A be h.
If mass of ball A is twice mass of ball B, then mass of ball A = 2m
If height of ball B is twice the height of ball A, it means that height of ball B is 2h
Thus,
GPE of ball A = 2m x g x h = 2mgh
GPE of ball B = m x g x 2h = 2mgh
Thus, both objects have the same GPE