(D) Metallic character is defined as the tendency of an element to lose electrons.
Across a period (from left to right),the metallic character decreases because the ionization enthalpy increases.
Down a group,the metallic character increases because the ionization enthalpy decreases.
Comparing the positions in the periodic table:
$K$ (Group $1$,Period $4$) is the most metallic.
$Mg$ (Group $2$,Period $3$) is less metallic than $K$ but more than $Al$.
$Al$ (Group $13$,Period $3$) is less metallic than $Mg$ but more than $B$.
$B$ (Group $13$,Period $2$) is the least metallic among these.
Therefore,the correct order is $K > Mg > Al > B$.