Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In order to illustrate that a subclass can access non - private elements of its superclass without any special syntax , try the following slightly
In order to illustrate that a subclass can access non private elements of its superclass without any special syntax try the following slightly artificial modification to the MessagePost and Post classes. Create a method called printShortSummary in the messagePost and Post class. its task is to print the phrase "Message post from NAME" where name should show the name of the author However, because the username field is private in the Post class It will be nessasary to add a public getUserName method to Post. Call this method from printShortSummary to access the name for printing remember that no special syntax is required when a subclass calls a superclass method. try out your solution bu creating a MessagePost object. Implement a similar method in the PhotoPost class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started