As 2 is a root of x2 + kx + 12 = 0 then it must satisfy it
therefore : (2)2 + k (2) + 12 = 0
=> 4 + 2k +12 = 0
=> k = -8
now using the value of k in the second equation
x2 + (-8)x + q = 0
this equation has equal roots, say a and a
so 2a = - (-8)/1
=> a = 4