Question

Consider that public class CBook extends Publication and in the driver class you have       CBook...

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

CBook c = new CBook(20, "Clifford the red dog" );
      System.out.println( c.toString( ) ); // Since refers to the string  Clifford the red dog so it print Clifford the red dog
      System.out.println("==========");

Output:

title: Clifford the red dog

Option c

2.

public class CBook extends Publication

and in the driver class

      CBook c = new CBook(20, "Clifford the red dog" ); // It just print c data that is Clifford the red dog
      System.out.println( c.title );    

Clifford the red dog

Option d

3.

Company code missing

CBook c = new CBook(20, "Clifford the red dog" );
      System.out.println( c.company

CBook@6d06d69c

because it uses the Object's toString method

Option d

Add a comment
Know the answer?
Add Answer to:
Consider that public class CBook extends Publication and in the driver class you have       CBook...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {    super();    System.out.println(“B() called”);...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {   super();   System.out.println(“B() called”); } public...

  • Consider the following codes: public class TestThread extends Thread {     public static void main(String[] args)...

    Consider the following codes: public class TestThread extends Thread {     public static void main(String[] args) {         TestThread thread = new TestThread();     }     @Override     public void run() {         printMyName();     }     private void printMyName() {         System.out.println("Thread is running");     } } Test Stem / Question Choices 1: What method should you invoke to start the thread TestThread? A: start() B: run() C: No. Thread will run automatically when executed. D: TestThread is not...

  • What is output? public abstract class People { protected string name; protected int age; public abstract...

    What is output? public abstract class People { protected string name; protected int age; public abstract void PrintInfo(); public void PrintInformation() { System.out.println("In Base Class People"); public class Teacher extends People { private int experience; public void PrintInfo() { System.out.println("In Child Class Teacher"); public class Principal extends Teacher { public void PrintInformation() { System.out.println("In Child Class Principal"); public static void main(String args[]) { Principal tim; tim = new Principal(); tim.PrintInfo(); In Base Class People Error: Compiler error In Child Class...

  • DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to...

    DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to be DataSetEmployee. DataSetEmployee should extend ArrayList<Employee> and have no instance variables. You'll have to decide what replaces the getPages concept for getMax/getMin. As a hint, what method of Employee returns a numeric value? Make a package com.acme.midmanager. This package should contain the Manager class. Make a package com.acme.personnel. This package should contain the DataSetEmployee class. Make a package com.acme.topmanagement. This package should contain the...

  • LAB: Book information (overriding member methods)

    10.15 LAB: Book information (overriding member methods)Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a printInfo() method that overrides the Book class' printInfo() method by printing not only the title, author, publisher, and publication date, but also the edition and number of volumes.Ex. If the input is:The Hobbit J. R. R. Tolkien George Allen & Unwin 21 September 1937 The Illustrated Encyclopedia of the Universe James W. Guthrie Watson-Guptill 2001 2nd 1the output is:Book Information:     Book Title: The Hobbit    Author: J. R. R. Tolkien    Publisher: George Allen & Unwin    Publication Date: 21 September 1937 Book Information:     Book Title: The Illustrated Encyclopedia of the Universe    Author: James W. Guthrie    Publisher: Watson-Guptill    Publication Date: 2001    Edition: 2nd    Number of Volumes: 1Note: Indentations use 3 spaces.BookInformation.javaimport java.util.Scanner; public class BookInformation {    public static void main(String[] args) {       Scanner scnr = new Scanner(System.in);       Book myBook = new Book();...

  • The method m() of class B overrides the m() method of class A, true or false?...

    The method m() of class B overrides the m() method of class A, true or false? class A int i; public void maint i) { this.is } } class B extends A{ public void m(Strings) { 1 Select one: True False For the following code, which statement is correct? public class Test { public static void main(String[] args) { Object al = new AC: Object a2 = new Object(); System.out.println(al); System.out.println(a): } } class A intx @Override public String toString()...

  • public class Game{ public void players() { System.out.println(“1 or more”); } } public class Chess extends...

    public class Game{ public void players() { System.out.println(“1 or more”); } } public class Chess extends Game { public void boardSize() { System.out.println(“8 by 8”); } public void players() { System.out.println(“2”); } } public class ThreeDChess extends Chess{ public void boardSize() {System.out.println(“7 levels”); } public void hasMoveableBoard() { System.out.println(“true”); } } Assume that these statements have already executed: Game g = new Game(); Chess c = new Chess(); ThreeDChess t = new ThreeDChess(); Object og = g; Game gc =...

  • Question 8 0 Consider the following class definitions, public class Class public String getValue() return "A";...

    Question 8 0 Consider the following class definitions, public class Class public String getValue() return "A"; public void showValue() System.out.print(getValue(); public class Classe extends Class public String getValue() return "B"; The following code segment appears in a class other than ClassA or Classe. ClassA obj = new Class(); obj.showValue(); What, if anything, is printed when the code segment is executed? c) AB ta PendulumPhysical.pdf ^ IN SHM Pendulums ....doc Moh PendulumPhysical.pdf Type here to search o Bi e а в...

  • Consider the following Java classes: class A{ public int foo () { return 1; } public...

    Consider the following Java classes: class A{ public int foo () { return 1; } public void message () { System.out.println( "A" + foo()); } } class B extends A { public int foo() {return 2; } } class C extends B { public void message () { System.out.println( "C" + foo()); } } (i) What are the outputs of the following code? (ii) What would be the outputs if Java used static dispatching rather than dynamic dispatching? B b...

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
ADVERTISEMENT
ADVERTISEMENT