1/15
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is class loading in Java?
The process of loading class bytecode into memory when it is referenced for the first time.
Which component loads classes in Java?
The ClassLoader.
What are the three main phases of class loading?
Loading, Linking, and Initialization.
What happens during the loading phase?
The class bytecode is read and a Class
object is created.
What are the steps in the linking phase?
Verification, Preparation, and (optionally) Resolution.
What is verification in class loading?
Checking the correctness of bytecode to ensure it adheres to JVM specifications.
What happens during preparation?
Memory is allocated for class variables and they are initialized to default values.
What is resolution in class loading?
Resolving symbolic references to actual memory addresses.
What happens during the initialization phase?
Static initializers and static blocks are executed.
What is a ClassLoader?
A part of the JVM responsible for dynamically loading classes at runtime.
What are the types of ClassLoaders in Java?
Bootstrap, Extension, and Application ClassLoader.
What is the bootstrap ClassLoader?
The default ClassLoader that loads core Java classes from the JDK.
What is the delegation model in class loading?
A model where ClassLoaders delegate the loading of classes to their parent before attempting to load themselves.
How can you create a custom ClassLoader?
By extending java.lang.ClassLoader
and overriding the findClass()
method.
Why might you use a custom ClassLoader?
To load classes from non-standard sources like encrypted files or remote servers.
What is the role of Class.forName()
?
It loads the class and initializes it if not already loaded.