Learn AP Comp Sci

Problem of the Day

Wednesday, December 17, 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 r given here do?

public static String r()
{
String[] let = {"Nun", "Gimel", "He", "Shin"};
return let[(int) (Math.random() * let.length)];
}
  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 c. The list of legal letters in the array let is established, and then a random index is created, and the letter at that index position returned.