LDC: Lower Division Clerk — Role, Skills & Exam Essentials: 20 flashcards
All 20 flashcards from this kit, free and with no sign-up.
1. What does the JVM opcode `ldc` stand for?
Show the answer
**Load Constant** — it loads a constant from the class's constant pool.
2. Where does `ldc` get its value from?
Show the answer
The current class's **constant pool**.
3. Where does `ldc` put the value it loads?
Show the answer
Onto the **operand stack**.
4. How wide is the index carried by `ldc`?
Show the answer
**1 byte** (0–255).
5. Which opcode replaces `ldc` when the constant pool has more than 255 entries?
Show the answer
`ldc_w`, which uses a **2-byte index**.
6. Which opcode must be used for `long` and `double` constants?
Show the answer
`ldc2_w` — they occupy **two operand-stack slots**.
7. Which single-slot constant types can `ldc` push?
Show the answer
`int`, `float`, `String`, `Class`, `MethodType`, `MethodHandle`, and `Dynamic` constants.
8. Why can't `ldc` push a `long` or `double`?
Show the answer
Because they take **two operand-stack slots**, so `ldc2_w` is required.
9. What is the constant pool's main efficiency benefit?
Show the answer
It **deduplicates** literals — repeated strings share one entry.
10. When are constant pool entries resolved?
Show the answer
**Lazily** — only when an `ldc` actually touches them.
11. How does `ldc` differ from `iload`/`aload`/`fload`?
Show the answer
The `*load` family reads **local variables**; `ldc` reads the **constant pool**.
12. Which instruction pushes a small integer literal without a pool lookup?
Show the answer
`bipush` (or `sipush` for slightly larger values).
13. How does `getstatic` differ from `ldc`?
Show the answer
`getstatic` pushes a **static field's value**; `ldc` pushes a **literal or symbolic reference**.
14. Which tool prints `ldc` lines with the pool index and a value comment?
Show the answer
`javap -c`.
15. What does the line `ldc #7 // String hello` tell you?
Show the answer
Opcode `ldc`, pool entry **7**, which is the string `hello`.
16. Is the constant pool global or per-class?
Show the answer
**Per-class** — each class has its own constant pool.
17. Why does `Class.forName("com.example.Foo")` involve `ldc`?
Show the answer
The class-name string is a literal, so `ldc` loads it before resolution.
18. What is the mental model for `ldc` in one line?
Show the answer
**Local variables live in the frame; constants live in the pool** — `ldc` bridges pool to stack.
19. Which opcode does the compiler pick when the pool index fits in 8 bits?
Show the answer
Plain `ldc` — the narrowest form that fits.
20. Do annotations and `invokedynamic` bootstrap arguments use `ldc`-family opcodes?
Show the answer
Yes — their arguments live in the constant pool and are fetched with `ldc`-family instructions.
Your notes can be a kit like these
Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.
- Chapter notes
- Flashcards
- Practice MCQs
- Scored tests
- Exam prep
Get Veda free See what students get
Free to start · No ads · Works in 42 languages