โ Back to Inheritance
Question 509
Cast With as
Cast With as
Doginherits fromAnimaland defines aBark()method. CompleteMakeItBarkso it casts theAnimalargument toDogusing theasoperator. If the cast succeeds (result is notnull) callBark(); otherwise printNot a dog. Do NOT write aMainmethod. For aDogargument the program prints: Woof For a plainAnimalargument the program prints: Not a dog
Expected Output:
Woof
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.