← Back to Polymorphism
Question 694
Default Interface Method
Default Interface Method
Give theIGreeterinterface a default methodGreet()that returns the textHi, <Name>!, built from the interface's ownNameproperty.Personalready implementsIGreeterby providingName, and it should NOT defineGreetitself — it will inherit the default. The tester callsGreet()through anIGreeterreference. Do NOT write aMainmethod. For aPersonnamedAdathe program prints: Hi, Ada!
Expected Output:
Hi, Ada!
Topics:
Polymorphism
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.