My custom widget won’t stay in the widget area after I refresh the widget page

ID Base should be passed to WP_Widget class constructor as shown in the following code, You have passes wrong id “example-widget” which does not match with “id_base”, also don’t add spaces in id base. Replace MY_Widget() function with following modified function and it will work.

function MY_Widget() {
    $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that creates a rollover image effect with a hyperlink. ', 'example') );

    $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'rollover-widget' );

    $this->WP_Widget( 'rollover-widget', __('Rollover Widget', 'example'), $widget_ops, $control_ops );
}