Class loading in Java

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/15

flashcard set

Earn XP

Description and Tags

Java

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

16 Terms

1
New cards

What is class loading in Java?

The process of loading class bytecode into memory when it is referenced for the first time.

2
New cards

Which component loads classes in Java?

The ClassLoader.

3
New cards

What are the three main phases of class loading?

Loading, Linking, and Initialization.

4
New cards

What happens during the loading phase?

The class bytecode is read and a Class object is created.

5
New cards

What are the steps in the linking phase?

Verification, Preparation, and (optionally) Resolution.

6
New cards

What is verification in class loading?

Checking the correctness of bytecode to ensure it adheres to JVM specifications.

7
New cards

What happens during preparation?

Memory is allocated for class variables and they are initialized to default values.

8
New cards

What is resolution in class loading?

Resolving symbolic references to actual memory addresses.

9
New cards

What happens during the initialization phase?

Static initializers and static blocks are executed.

10
New cards

What is a ClassLoader?

A part of the JVM responsible for dynamically loading classes at runtime.

11
New cards

What are the types of ClassLoaders in Java?

Bootstrap, Extension, and Application ClassLoader.

12
New cards

What is the bootstrap ClassLoader?

The default ClassLoader that loads core Java classes from the JDK.

13
New cards

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.

14
New cards

How can you create a custom ClassLoader?

By extending java.lang.ClassLoader and overriding the findClass() method.

15
New cards

Why might you use a custom ClassLoader?

To load classes from non-standard sources like encrypted files or remote servers.

16
New cards

What is the role of Class.forName()?

It loads the class and initializes it if not already loaded.