Given,
Object distance u=40 cm
Image distance v=20 cm
As per sign convention, object distance is taken as negative. Since the image is formed on the other side of the mirror, image distance is positive.
u=−40 cm
v=+20 cm
Using the mirror formula,
1u+1v=1f
1f=1−40+120
1f=140
f=+40 cm
The focal length is positive for a convex mirror. Hence, the mirror in this case is convex.