1. A method for preventing a malicious code in an electronic device, the method comprising: converting a suspicious operation code to a logging operation code; executing the converted logging operation code; and displaying predictive operation information related to the logging operation code according to the result of execution.