Solenoid behaves like a magnet as it has a soft iron core with insulated copper wire over it. When a current is passed through the solenoid, a magnetic field is produced around it. The magnetic field produced is similar to the magnetic field of a bar magnet. Field lines produced by solenoid are shown in the attached diagram. If the north pole of a bar magnet is brought near the negative terminal of the battery, then the solenoid repels the bar magnet as like poles repel each other; similarly, the other end behaves as a south pole.