Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

3. Describe the communicative power of group affiliations

Answered: 1 week ago