What is the ClassLoader in Java?
Answer
A ClassLoader is responsible for loading Java class files (.class bytecode) into the JVM at runtime. The JVM uses a delegation hierarchy: Bootstrap ClassLoader (loads core Java classes from rt.jar/modules), Extension/Platform ClassLoader (loads extension libraries), and Application ClassLoader (loads classes from the classpath). When a class is requested, the child loader asks the parent first (delegation model) — this prevents malicious classes from replacing core Java classes. You can create custom ClassLoaders for dynamic class loading, hot deployment (reloading classes without restarting), or loading from non-standard sources (databases, networks). This is how application servers like Tomcat isolate different web applications.
Previous
What are text blocks in Java?
Next
What is the Singleton design pattern and how is it implemented in Java?