I am using Raspberry pi in college lab. There is lot of wall sockets which are connected serially. If I turns on or off other devices on the lab suddenly my Raspberry Pi display become blank for few seconds. After few seconds this comes back. But my data is not loosing these times. Sometimes I also noticed that there is some rainbow coloured boxes on the display while this thing is happening. What is the reason behind this? Is there is any chances for turning on and off other devices harm our Pi?
It sounds like you have electrical power stability problems. Having a stable power source for your RPi is very important. The USB power converter (or charger) should be capable of providing 2 to 2.5 amps. The rating should be printed on the device. Many phone chargers and inexpensive USB chargers provide only 1 amp or less.
If you have a good quality USB power converter and are still having problems, then you may have a problem with your main power source (i.e. wall outlets). That will require a professional electrician to fix.
Not supplying sufficient and stable power to the RPI can cause unpredictable and potentially damaging behavior. The SD cards are especially sensitive to power issues and can easily get corrupted. When this happens, you could lose a lot of data. That's why it's always a good idea to have a backup.