Learn AP Comp Sci

Problem of the Day

Tuesday, December 16, 2025


Problem:

During the Jewish festival Hannukah, the dreidel game is played with a small, four-sided, spinning top. Each of the four faces is imprinted with a Hebrew letter, and when the top is spun, one of the four letters will land face up. Hebrew letters can be displayed in a webpage by using a numeric character reference according to the table here.

Letter NameHebrew LetterHTML reference
"Nun"ננ
"Gimel"גג
"He"הה
"Shin"שש

What does the method d given here do?

public static String d(String letter)
{
String[] let = {"Nun", "Gimel", "He", "Shin"};
String[] cod = {"נ", "ג", "ה", "ש"};
for (int i = 0; i < let.length; i++)
if (let[i].equals(letter))
return cod[i];
return null;
}
  1. Identifies the HTML code for a given LetterName
  2. Identifies the HTML code for a given Hebrew letter
  3. selects a random Hebrew letter
  4. selects a random HTML reference for a Hebrew letter

Show solution:

The correct answer is a. The parameter letter is compared with the list of legal letters in the array let, and the corresponding HTML reference from the array cod is returned, or null if a legal match isn't found.