Have you ever wondered why most people can tell which color they see but they most likely cannot label a note they hear without having a reference note? The second ability is known as absolute pitch (AP) or perfect pitch and is rather rare in Europe and North America. Only one of 10000 people possess this ability, e.g. some popular musicians such as Mozart. 
There already has been considerable interest and research about where AP stems from but it still is an unanswered question. By searching the internet you will find several websites telling you that they can teach you to get AP. But from a scientific perspective it is not proven that this is possible: Only one study has shown that a learning process of about 60 hours led to some kind of success.  This seems much of an effort compared to the essentially unconscious learning of AP in childhood.
There are basically three different explanations for the genesis of AP:
- training makes it possible (this is what the websites mentioned above will tell you)
- genes are responsible
- learning is feasible but only if you start at a young age
The genetic origin of AP is supported by the fact that young children already possess it and that it is more likely to have AP if there are other family members with AP. Of course in the latter case it is possible that young children get “trained” by these family members and do not just have it in their genes. But in fact there is some scientific evidence that a specific part of the genome could – at least partly – be the reason. 
There are also reports about the benefit of an early start of musical training. Another distinctive feature is the linkage to the acquisition of speech in infancy. There are differences between speakers of nontone languages like English and tone languages, e.g. Mandarin or Vietnamese. Tone language speakers seem to have an advantage, which is possible due to some kind of training effect in tone languages: The meaning of some words changes if you use another pitch. So children that are speakers of a nontone language have to learn more about pitches when they start musical training.
Up to now we can only speculate that the right composition of these requirements could be the clue to gain AP.
If you want to test yourself, you should have a look at http://www.absolutepitchstudy.com/index.html.
 Deutsch, D. Absolute pitch. In D. Deutsch (Ed.). The psychology of music, 3rd Edition, 2013, 141-182, San Diego: Elsevier.
 Brady, P. T. Fixed scale mechanism of absolute pitch. Journal of the Acoustical Society of America, 1970, 48, 883-887.
 Elizabeth Theusch, Analabha Basu, Jane Gitschier, Genome-wide Study of Families with Absolute Pitch Reveals Linkage to 8q24.21 and Locus Heterogeneity, The American Journal of Human Genetics 85, 112–119, 2009.