I am assuming that in case of Animal myPet = new Cat(); you want to get Cat not Animal nor myPet.
To get only name without package part use
String name = theVariable.getClass().getSimpleName(); //to get Cat
otherwise
String name = theVariable.getClass().getName(); //to get full.package.name.of.Cat