Question 1: What is the primary responsibility of the ClassLoader in Java?
- Execute bytecode
- Load classes into JVM memory
- Manage heap memory
- Optimize bytecode
Explanation: ClassLoader loads class bytecode into JVM memory.
This advanced Core Java quiz is designed for experienced Java developers preparing for senior-level interviews. It covers JVM internals, memory management, concurrency, collections internals, design principles, performance tuning, and real-world Java problem-solving scenarios.
Explanation: ClassLoader loads class bytecode into JVM memory.
Explanation: Metaspace stores class metadata in Java 8+.
Explanation: PermGen was replaced by Metaspace.
Explanation: G1 GC aims to reduce pause times.
Explanation: volatile guarantees visibility of changes across threads.
Explanation: synchronized ensures mutual exclusion.
Explanation: It minimizes synchronization overhead while maintaining safety.
Explanation: ArrayList is not synchronized.
Explanation: ConcurrentHashMap supports concurrent access with fine-grained locking.
Explanation: Lack of synchronization causes race conditions.
Explanation: Concurrent modification may cause infinite loops.
Explanation: @FunctionalInterface enables lambda expressions.
Explanation: Lambdas work with functional interfaces.
Explanation: Streams support functional-style data processing.
Explanation: map() transforms elements.
Explanation: collect() is a terminal operation.
Explanation: Fork/Join supports parallelism.
Explanation: ClassNotFoundException occurs during dynamic loading.
Explanation: Errors represent serious system problems.
Explanation: Java design aligns strongly with SOLID principles.
Explanation: Immutable objects are inherently thread-safe.
Explanation: Immutability allows caching and thread safety.
Explanation: Static inner classes enable lazy loading.
Explanation: Escape analysis optimizes memory allocation.
Explanation: Scalar replacement avoids heap allocation.
Explanation: JIT compiles bytecode into native code.
Explanation: final allows aggressive JVM optimizations.
Explanation: Weak references allow GC cleanup.
Explanation: TreeMap is based on red-black tree.
Explanation: equals() affects HashMap and HashSet behavior.
Explanation: hashCode must align with equals.
Explanation: Race conditions cause inconsistent results.
Explanation: Threads keep responding without progress.
Explanation: FixedThreadPool suits CPU-bound workloads.
Explanation: Checked exceptions increase coupling.
Explanation: Serializable enables object persistence.
Explanation: It requires manual serialization logic.
Explanation: Singleton restricts instantiation.
Explanation: Double-checked locking is lazy and efficient.
Explanation: Singletons hinder testability.
Explanation: DIP encourages abstraction-based design.
Explanation: Interfaces support multiple inheritance.
Explanation: Reflection impacts performance and security.
Explanation: Core Java builds strong, scalable foundations.
This advanced Core Java quiz is designed for experienced Java developers preparing for senior-level interviews. It covers JVM internals, memory management, concurrency, collections internals, design principles, performance tuning, and real-world Java problem-solving scenarios.