Problem

In order to illustrate that a subclass can access non-private elements of its superclass...

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.

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT