Question: Use the following code to answer the questions in this part ++++++++++++++++++ public class Publication{ protected int pages = 0; protected String title = publication
Use the following code to answer the questions in this part
++++++++++++++++++
public class Publication{ protected int pages = 0; protected String title = "publication title"; }
+++++++++++++++++++ public class PBook extends Publication{
protected int pages = 100; protected String title = "book title"; public String toString( ){ String s = "title: " + this.title + " pages: "+ this.pages; return s; } }
+++++++++++++++++
public class Pamphlet extends Publication{
protected String company = "company pamphlet"; }
+++++++++++++++++
public class CBook extends ___________ {
protected int pages = 100; protected String title = "Children Book"; public CBook(int pages, String title){ this.pages = pages; this.title = title; } public String toString( ){ String s = "title: " + this.title; return s; } }
Consider that
public class CBook extends Publication
and in the driver class you have
CBook c = new CBook(20, "Clifford the red dog" ); System.out.println( c.toString( ) ); System.out.println("==========");
What will be printed?
| A. | title: book title | |
| B. | title: Children Book title pages: 100 | |
| C. | title: Clifford the red dog | |
| D. | error because title is protected |
Consider that
public class CBook extends Publication
and in the driver class
CBook c = new CBook(20, "Clifford the red dog" ); System.out.println( c.title );
What will be printed?
| A. | CBook@6d06d69c because it uses the Object's toString method | |
| B. | error because title is protected | |
| C. | title: Clifford the red dog | |
| D. | Clifford the red dog |
Consider that
public class CBook extends Pamphlet{
and in the driver class
CBook c = new CBook(20, "Clifford the red dog" ); System.out.println( c.company
What will be printed?
| A. | error because pages are missing | |
| B. | title: Clifford the red dog | |
| C. | company pamphlet | |
| D. | CBook@6d06d69c because it uses the Object's toString method |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
