Check out your camera manual and look for spot metering mode and how to activate it. Also, google this and watch an online video on the subject (I'm sure they explain it better than I can and have example pics and instructions). Basically, digital cameras in automatic mode try to find the correct exposure for what is in the viewfinder. This works well most of the time, but in situations like you have where the contrasts are extreme (bright sunlight versus dark shade) or complex (light foreground, shadow mid ground, light background), the camera gets confused and gives you an exposure that just isn't what you want. With spot metering, rather than trying to properly expose everything in the picture, you TELL the camera what the subject is and it then sets that object exposure correctly, and ignores the rest of the image. In your case, you would spot meter on the guitar and this would produce a well exposed guitar, but a very dark middle ground shadow. For spot metering you basically have a small dot in the viewfinder you can move around with a thumb control until it is on the thing you want exposed, and then the camera will adjust things so that object will be exposed properly. In some cameras it is just a dot that you have to put on the subject by moving the composition. This mode is also super useful when you are trying to take a picture of a person with a very bright background (set the exposure/metering dot on the person, and you will get a good pic of the person and an overexposed background), pictures of the moon, pictures of snow, pictures in fog, and pics in very high contrast areas. It is probably useful for other stuff too, but these are what come to mind.
One way to avoid this in the future, as these pics often look OK on the small LCD preview panel, and fine through the viewfinder, is to use the camera's histogram function. You would see the overexposure of this image as a giant peak on the right side of the histogram, and then you would get a good idea that you were overexposed. I use the histogram for almost every picture, and most cameras let you display this on the preview window for each new picture. It is a good habit to get into having this one there and just giving it a quick glance to see that things tend to be in the middle of the histogram with limited peaks on the ends. On my camera there is an info button that will display the histogram when it is pushed a couple of times.