I read a few posts here about the magic number 0xCAFEBABE in the beginning of each java .class file and wanted to know why it
0xCAFEBABE
The magic number is basically an identifier for a file format. A JPEG for example always starts with FFD8. It is not necessary for Java itself, it simply helps to identify the file-type. You can read more about magic numbers here.