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.
Use the debugger to examine the clock-display project. Set breakpoints in the ClockDisplay constructor and each of the methods, and then singlestep through them. How do you feel about the way it's behaving? Have you gained any fresh insights as a result of this? If this is the case, what exactly were they?
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