LDC: Lower Division Clerk — Role, Skills & Exam Essentials: 18 MCQs with answers

All 18 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 6 questions

Q1. What does the JVM opcode `ldc` stand for?

Beginner
A Link Dynamic Class B Local Data Copy C Load Constant D Long Double Convert
Show answer & explanation

Load Constant

`ldc` expands to **Load Constant**. It is the JVM instruction that fetches a constant from the class's constant pool and pushes it onto the operand stack.

Q2. Where does `ldc` read its value from?

Beginner
A The top of the operand stack B A local variable slot C A static field of the class D The class's constant pool
Show answer & explanation

The class's constant pool

`ldc` reads from the **constant pool** of the current class. Local variables are read by the `*load` family (`iload`, `aload`, `fload`), and static fields by `getstatic`.

Q3. How many bytes wide is the constant pool index carried by plain `ldc`?

Beginner
A 1 byte B 4 bytes C 2 bytes D 8 bytes
Show answer & explanation

1 byte

`ldc` carries a **1-byte unsigned index** (0–255), which keeps the bytecode compact. The 2-byte form is `ldc_w`.

Q4. Which opcode must be used to push a `double` constant?

Beginner
A `ldc` B `ldc2_w` C `dload` D `ldc_w`
Show answer & explanation

`ldc2_w`

`long` and `double` occupy **two operand-stack slots**, so they require `ldc2_w`. Plain `ldc` handles only single-slot values.

Q5. A compiler emits `ldc #7 // String hello`. What does the `#7` refer to?

Beginner
A Local variable slot 7 B The 7th method of the class C Byte offset 7 in the method D Entry 7 in the class's constant pool
Show answer & explanation

Entry 7 in the class's constant pool

The number after `ldc` is the **constant pool index**. Entry 7 in this class's pool holds the string `hello`, which `javap` helpfully prints as a comment.

Q6. **ldc** is a JVM bytecode instruction that loads a constant from the class's constant pool onto the operand stack, using a 1-byte index.

Beginner
A True B False
Show answer & explanation

True

**ldc** is a JVM bytecode instruction that loads a constant from the class's constant pool onto the operand stack, using a 1-byte index.

Building up · 7 questions

Q7. A class's constant pool has grown to 400 entries. Which opcode will the compiler use for a `String` literal?

Intermediate
A `ldc2_w` B `ldc` C `ldc_w` D `sipush`
Show answer & explanation

`ldc_w`

A 1-byte index can only address 0–255, so a 400-entry pool needs the **2-byte index** of `ldc_w`. `ldc2_w` is reserved for `long` and `double`.

Q8. Why does the JVM keep literals in a constant pool instead of inlining them in bytecode?

Intermediate
A It makes every literal occupy two stack slots B It removes the need for an operand stack C It deduplicates literals and allows lazy resolution D It converts strings into local variables
Show answer & explanation

It deduplicates literals and allows lazy resolution

The pool **deduplicates** repeated literals — one entry, many `ldc` references — and enables **lazy resolution**, so a class reference is not loaded until an `ldc` actually touches it.

Q9. Which statement correctly contrasts `iload_1` with `ldc 5`?

Intermediate
A `iload_1` pushes a pool constant; `ldc 5` reads a local variable B Both read from the constant pool but differ in index width C `iload_1` reads a local variable; `ldc 5` pushes a pool constant D Both read from local variable slots but differ in type
Show answer & explanation

`iload_1` reads a local variable; `ldc 5` pushes a pool constant

The `*load` family reads **local variable slots** in the stack frame, while `ldc` reads the **constant pool**. They share the word "load" but are unrelated mechanisms.

Q10. Which of these constants can plain `ldc` push directly?

Intermediate
A A `double` literal such as `2.0` B A `Class` literal such as `String.class` C A local `int` variable's current value D A `long` literal such as `5L`
Show answer & explanation

A `Class` literal such as `String.class`

`ldc` handles single-slot constants including `int`, `float`, `String`, `Class`, `MethodType`, `MethodHandle` and `Dynamic`. `long` and `double` need `ldc2_w`, and local variables need `*load`.

Q11. A student writes `int i = 5;` and `long x = 5L;`. Why do the two statements compile to different constant-loading opcodes?

Intermediate
A `int` literals are always stored in local variables B `long` takes two stack slots, so it needs `ldc2_w` C `int` literals are resolved eagerly at class load time D `long` literals cannot be stored in a constant pool
Show answer & explanation

`long` takes two stack slots, so it needs `ldc2_w`

The deciding factor is **operand-stack slot count**: `long` and `double` occupy two slots, so the JVM provides `ldc2_w` for them. Both values still live in the constant pool.

Q12. Which instruction pushes the value of a **static field**, rather than a literal?

Intermediate
A `bipush` B `ldc` C `ldc_w` D `getstatic`
Show answer & explanation

`getstatic`

`getstatic` reads a **static field's value**. `ldc` and its variants push constants from the pool, and `bipush` pushes a small integer literal inline.

Q13. Why does `System.out.println("Hi");` contain an `ldc` in its bytecode?

Intermediate
A The return value of `println` is stored in the pool B `System.out` is a constant that must be loaded C The string literal `"Hi"` must be pushed from the constant pool D `println` is a static method that needs a pool reference
Show answer & explanation

The string literal `"Hi"` must be pushed from the constant pool

`System.out` is fetched with `getstatic`, but the argument `"Hi"` is a **string literal**, so the compiler emits `ldc` to push it onto the operand stack before `invokevirtual`.

Topper level · 5 questions

Q14. A developer wants to see exactly which constant pool entry each `ldc` uses in a compiled class. Which command is appropriate?

Advanced
A `jdb` attached to a running process B `javap -c` on the class file C `javac -g` on the source file D `java -version` on the JVM
Show answer & explanation

`javap -c` on the class file

`javap -c` disassembles the class and prints each `ldc` with its **pool index and a comment** showing the value, e.g. `ldc #7 // String hello`. That is the fastest way to read stack-based execution.

Q15. Consider these statements about the constant pool: I. It is shared globally across all loaded classes. II. Entries are resolved lazily, only when touched. III. Repeated string literals share a single entry. Which are correct?

Advanced
A I and II only B I and III only C I, II and III D II and III only
Show answer & explanation

II and III only

The constant pool is **per-class**, not global, so statement I is wrong. Statements II (lazy resolution) and III (deduplication) are both correct.

Q16. A method contains `String.class` and `Class.forName("com.example.Foo")`. What do these two constructs have in common at the bytecode level?

Advanced
A Both use `ldc2_w` because class references take two slots B Both compile to `getstatic` followed by `invokevirtual` C Both avoid the constant pool entirely D Both rely on `ldc` to push a pool entry before resolution
Show answer & explanation

Both rely on `ldc` to push a pool entry before resolution

A `Class` literal and the class-name string passed to `Class.forName` are both **constant pool entries**, so `ldc` pushes them before the JVM resolves the class. Neither takes two slots, so `ldc2_w` is not involved.

Q17. A developer is optimizing a Java application with a large constant pool containing over 300 entries. They want to ensure efficient bytecode generation for string literals. Which instruction should they expect to see in the compiled bytecode for a string literal?

Advanced
A getstatic B ldc C ldc_w D bipush
Show answer & explanation

ldc_w

The correct option is `ldc_w` because it is used for constant pools with more than 255 entries, ensuring that the string literal can be correctly referenced without exceeding the index limit.

Q18. Consider a Java method that includes the following lines of code: `String str = "Hello"; double value = 3.14;`. When compiled, which of the following bytecode instructions will be generated for these lines, and why?

Advanced
A Both will use `ldc` B The string uses `ldc`, while the double uses `ldc2_w` C Both will use `ldc_w` D The string uses `bipush`, while the double uses `ldc`
Show answer & explanation

The string uses `ldc`, while the double uses `ldc2_w`

The correct option is that the string uses `ldc` because it fits within a single slot, while the double requires `ldc2_w` because it occupies two slots on the operand stack.

Make your own

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