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

4.1 Objects and fields — safe name

Total: 0 / 3 pts
Practice mode — check each part and get hints as you go.
Task

Fill in safeName so that it returns the dog's name — or the text unknown when it is given null instead of a dog.

The program prints Rex and then unknown. Without the guard the second call would crash with a NullPointerException.

Your solution