CJCoding With Joseph
15free / daySign inCreate account

pointsOf receives an Account, but only a PremiumAccount has getRewardPoints(). The compiler will not let you call that method on a variable of type Account. You first check what the object really is with instanceof, then cast it down to the subclass type, and then the method is available.

Requirements: 1. When account is a PremiumAccount, pointsOf returns its reward points. 2. For a plain Account it returns 0. 3. Test with instanceof before you cast. Casting a plain Account to PremiumAccount would crash the program.

The Account and PremiumAccount classes are provided. Do not change them.

Do NOT write a main method.

Expected output

0
1200

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

Hints4 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.