Dear Student,
Answer to your question is given below:
We know that in case of magnets, unlike poles attract each other while like poles repel each other.
Iron bar A is attracted by a magnet at one end and repelled by magnet at the other end, hence it is a magnet.
While, iron B is attracted by a magnet at both ends, hence it is not a magnet.
Regards,