← Back to Inheritance
Question 195
Inherit and Call Super Method
Inherit and Call Super Method
AVehicleclass is provided with a methoddescribe()that returns"I am a vehicle". Complete theTruckclass that extendsVehicle. Requirements: 1. Overridedescribe()to return the parent's description followed by" - specifically a truck". You must callsuper.describe()to get the parent's text. So the final output ofdescribe()should be:"I am a vehicle - specifically a truck". Do NOT write a main method.
Expected Output:
I am a vehicle - specifically a truck= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
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.