I figured it out myself,if we define the key to be of type String and it contains only numerals due to the internal working of the coherence server,it returns null.
in short
key defined as string - key contains alphanumeric - WORKS
key defined as string - key contains only alphabets - WORKS
key defined as string - key contains only numbers - DOES NOT WORK
so what I did was , before putting the data in the cache , I did a check on the key whether it contained only numbers using
if (code.matches("[0-9]+"))
If yes, then store the key as an integer, else store it as a string.
Now I am able to retrieve the values for all cases.
ANOTHER SOLUTION -
Instead of storing the key as an integer, even if it is a numeral stored as a string then while doing get
get \ 111
this retrieves the correct values too