Question: I recently bought a Nikon D5100. And along with this camera, I got the AF-S DX NIKKOR 18-55mm f/3.5-5.6G VR lens as kit. It's "G" type lens, right?

One of my friend suggested to buy a 50mm f/1.8D prime lens for a good aperture. I bought it too, and it's "D" type lens.

Main thing is I'm confused about what these "G" and "D" type lens means. I know it's a common question but I didn't find any solid answer.

Answer: 
Here is the description from Nikon's own web site:

**D-Type NIKKOR Lenses**
A D-type lens relays subject-to-camera-distance information to Nikon D-SLRs that feature 3D Color Matrix Metering (all versions), 3D Matrix Metering, 3D Multi-Sensor Balanced Fill-Flash and i-TTL Balanced Fill-Flash. Many D-Type lenses have an aperture control ring and can be used on older Nikon SLR cameras that allow for manual control of the aperture, as well as on D-SLRs—especially useful for adjusting aperture while recording D-Movies on higher end models. When used on a D-SLR, the aperture control ring needs to be locked at the smallest possible aperture (generally designated in orange), and the aperture control is maintained through the camera's command dial

**G-Type NIKKOR Lenses**
A G-type lens does not have an aperture control ring and are intended for use on Nikon D-SLRs that allow the lens aperture to be adjusted via the camera's command dial. Because G-type lenses relay subject-to-camera-distance information to the camera, where it is used to help determine ambient and flash exposure, they are also considered to be D-type lenses. The lack of an aperture control ring is perhaps the easiest way that you can tell if a lens is a G-Type NIKKOR or not. [The AF-S NIKKOR 24-120mm f/4G ED VR lens, shown above is an example of a G-Type lens. Note there is no aperture ring on that version of the lens, while there is an aperture ring on the AF version, above right.]

<http://www.nikonusa.com/en/Learn-And-Explore/Article/go35b5yp/which-nikkor-lens-type-is-right-for-your-d-slr.html>

To me the main different is that a G lenses are newer lenses where Nikon have removed the aperture ring.
Any G lens is a D lens. Not all D lenses are G lenses.  

The difference is that a G lens lacks an aperture ring for manually setting the aperture on the lens (rather than the camera). This isn't very important on modern cameras (everything producedin the last 20 years or so) except sometimes in full manual mode it can be more convenient than using the camera controls.  

The reason he advised that lens is not that it's a D rather than a G lens, but because its far wider maximum aperture makes it much more capable in low light situations than the lens you already have (it can capture a lot more light, meaning shorter exposure times). It's also optically far superior to your kit lens, giving better photos with less distortion and lens artifacts. Neither is related to D vs. G, it's just differences in the design and materials used in the lens construction.  

The main reason to omit an aperture ring on many current lenses is cost (it's extra construction, materials, etc.), and there being no space for one on a lens that has VR (the number of contacts on the electronic linking between the lens and body means Nikon could not design a lens that has both VR and an aperture ring without changing their lens mount, which would break compatibility between new and existing lenses and bodies, which they've always avoided).