Skip to content

GladLibs :Java Programming: Arrays, Lists, and Structured Data (Java Programming and Software Engineering Fundamentals Specialization) Answers 2025


Question 1

Correct Answer:
✔️ If a word is a repeated word, then this code gets another random word and uses that second word without checking to see if it is a repeated word.

Explanation:
The break inside the if stops the loop immediately—so the new substitute is never re-checked.


Question 2

✔️ processWord
❌ GladLibs constructor
❌ myStory
❌ getSubstitute

Explanation:
processWord is where each tag replacement occurs, so that’s where the counter is incremented.


Question 3

✔️ 104 (unique words in errors.txt)


Question 4

✔️ the (most frequent word)


Question 5

✔️ 13 (occurrences of the most common word)


Question 6

✔️ macbeth (fewer than 100 lines but most speaking parts)


Question 7

✔️ claudius – 68 speaking parts


Question 8

✔️ 6 characters have 10–15 speaking parts.


Question 9

✔️ 34 unique codons (reading frame starting at position 1)


Question 10

✔️ 23 occurrences of the most frequent codon (reading frame starting at position 2)


Question 11 — Select all

✔️ ATG
❌ GAT
✔️ CAG
❌ TGT
✔️ CAA
❌ GCC


Question 12

✔️ 15 words appear in all seven files


Question 13

✔️ 48 words appear in exactly four of the seven files


Question 14

✔️ likeit.txt (does NOT contain “laid”)
❌ all others


Question 15 — Select all

✔️ hamlet.txt
✔️ macbeth.txt
✔️ romeo.txt
❌ caesar.txt
❌ confucius.txt
❌ errors.txt
❌ likeit.txt


Question 16

✔️ initializeFromSource
❌ constructor
❌ HashMap definition
❌ readIt
❌ makeStory


Question 17

✔️ readIt
❌ initializeFromSource
❌ constructor
❌ automatic map creation
❌ makeStory


Question 18 — Correct possibilities

✔️ sum += words.size();
✔️ sum += myMap.get(category).size();

All others ❌


Question 19

✔️ processWord
❌ totalWordsConsidered
❌ readIt
❌ getSubstitute
❌ makeStory
❌ fromTemplate


📌 Summary Table

Q# Answer
1 If repeated → new word not re-checked
2 processWord
3 104 unique words
4 “the”
5 13 occurrences
6 macbeth
7 claudius — 68
8 6 characters
9 34 codons
10 23 occurrences
11 ATG, CAG, CAA
12 15 words
13 48 words
14 likeit.txt
15 hamlet, macbeth, romeo
16 initializeFromSource
17 readIt
18 Options 1 & 4
19 processWord