I am creating a sample demo program for make me understand that how can I deallocate the reference of static variables, methods in java using garbage collector?
I a
Other than the program, to answer your question
No. Methods are not garbage collected because they don't exist in the heap in the first place.
Static variables belong to the Class instance and will not be garbage collected once loaded (for most of the general Classloaders)