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

7.5 Type checks and casting — count the dogs

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

Fill in countDogs so that it returns how many elements of the array are really Dog objects.

The array is typed Animal[], so you cannot tell by the declared type — ask each object with instanceof. The program prints 2 and then 0.

Your solution