Task 7 of 7 · 0 solved · 7 to go0%
You can read the problem, but answers are checked only for signed-in students. Sign in to answer →

Problem

9.2 Generic methods — capstone: bounded search

Write a complete program with two generic methods: maxOf with the bound <T extends Comparable<T>> returning the largest element, and countOccurrences counting elements equal to a target.

Read a count, that many words, and then one more word to search for. Print the alphabetically largest word, then how many times the search word appears.

For 3, pear apple fig, apple:

pear
1

maxOf needs the bound to call compareTo; countOccurrences works unbounded because equals exists on every object.

time 1000 ms memory 256 Mb
Solution
Attempts: 0 A hint guides you to the fix — it never writes the code for you.
✦
Ready to check

Press «Submit» to run your code against the task's test cases — that is what sets your score. «AI review» is an optional second opinion: it reads your code — logic and style, not just the output — and suggests the next step without handing over the answer. It never changes your score.

Next module →
Working…