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 class. Its task is to print just 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 necessary 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 by creating a MessagePost object. Implement a similar method in the PhotoPost class.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.