If your Alfresco 4.0.d has no customizations it should be as easy as, stop alfresco, replace alfresco.war and share.war. Delete webapps/alfresco and webapps/share and restart Alfresco.
It should detect that you are updating and it will run the neccesary scripts to do so.