Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 11, Problem 1E

Explanation of Solution

Given: The network project version and the display method is in the Post class.

To find:

The display method is shifted into the class MessagePost and PhotoPost.

The result on compilation of the program.

Solution:

The program shows compile time error after shifting the display() method from Post class to MessagePost and PhotoPost.

The MessagePost and PhotoPost are the subclasses of Post class. The private members can access only from the member function of the same class. The display() method tries to access the private members of the Post class from the subclasses MessagePost and PhotoPost. Therefore, it shows compile time error. A public member function created in the Post class and calling that from the display method removes error.

It also shows error in NewsFeed class because the NewsFeed class calls the display() method with the object of type Post and the display method is not in the Post class. Hence, it shows compile time error.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Write out what you think the outer wrappers of the Student and LabClass classes might look like; do not worry about the inner part.
Write the code for the timeTick method in ClockDisplay that displays hours, minutes, and seconds, or even implement the whole class if you wish.
Create a new project for this program called TestOldMaid and add a class with a main() method. In the project: Copy your Deck and Card class from the earlier project into it. Create a subclass of Deck called OldMaidDeck. It is special because one of the Queens is missing so it only has 51 cards. Create a constructor method that calls the super class constructor, then removes a queen. Override the toString method so it returns the name of the deck and the number of cards in it. Write the test main() method. Create an OldMaidDeck object and deal all the cards to six players. It is ok if not everyone has an equal number of cards. Use arrays or ArrayLists for the players hands. Show the hands of all 6 players. Refer to the web to find out more about the Old Maid card game: https://bicyclecards.com/how-to-play/old-maid/ Fully document all classes with your name, date and description. And each data member and method is documented. Each block that does something is also documented.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education