CJCoding With Joseph
15free / daySign inCreate account

A Player[] array can hold plain Player objects and Goalie objects, because a Goalie is a Player. The instanceof operator tells you what an object really is at run time: x instanceof Goalie is true only when x refers to a Goalie. Complete the loop in countGoalies.

Requirements: 1. countGoalies(Player[] team) returns how many elements of team are Goalie objects. 2. The loop, the counter and the return statement are written. Add the test inside the loop.

The Player and Goalie classes are provided. Do not change them.

Do NOT write a main method.

Expected output

2

= newline. The output ends with a newline, so print one after the last line.

Hints3 available
Topics
InheritanceClasses
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.