The serial pins (DIN and DOUT) of the XBee are connected through an SPDT switch, which allows you to select a connection to either the UART pins (D0, D1) or any digital pins on the Arduino (D2 and D3 default).
Which is wrong. The switch connects the XBee to pins 0 and 1 or
2 and 3 (not any digital pins).
You haven't said what position the switch is in, or what code is running on the Mega.
when ever i tried make a connection via x-ctu couldn't work
X-CTU is used to configure XBees. That thing is NOT an XBee. It is a bluetooth device in a XBee form factor.
i also tried via arduino IDE to communicate and also failed.
Maybe you needed to use a tennis racket. Using the Arduino IDE to try to communicate with the bluetooth device makes no sense. The Arduino IDE is used to write programs that are compiled, linked, and uploaded to the Arduino.
You might as well be trying to use Word.
When i try this with shield on it it gives me the 'Time out' message.
This implies that you have the switch in the position where the bluetooth device is connected to the serial pins (0 and 1) that the upload process is trying to use to upload the sketch. YOu can't do that.