>>>1)When class will loaded into memory?
-- when program refers class for first time or regardless of that?
-- if it will be loaded regardless of its reference, then how classes are loaded, I mean how class loader comes to know, which classes needs to be loaded.
JVM has classloader whenever you instantiate JVM by entering "java xyz", JVM classloader will know and load your xyz class because with
java you are specifiying class name "xyz".
2)What exactly happens when class is loaded?
When classloader of JVM or user-defined class loader load the class, it will send that class to execution engine of JVM at runtime which executes the bytecode defined in classloader class.
3)What is difference between instantiating and loading?
Once claas is loaded it remains in classloader and whenever you instantiate it, it will call the class file.