![tierann46](/avatars/26816.jpg)
tierann46
20.09.2020 •
Computers and Technology
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
Solved
Show answers
More tips
Answers on questions: Computers and Technology
- C Computers and Technology Select the correct answer. Which statement is true when you are planning contents of your digital portfolio to show to prospective employers? A. Share your photograph...
- C Computers and Technology With software prefetching, it is important to be careful to have the prefetches occur in time for use but also to minimize the number of outstanding prefetches...
- C Computers and Technology Join my zom please id: 5231210760 pass: 0CHTAZ...
- C Computers and Technology You have the right to be free from in the workplace when exercising safety and health rights....
- C Computers and Technology Which type of virus includes protective code that prevents outside examination of critical elements?...
- C Computers and Technology For many cryptographic algorithms, it is necessary to select one or more very large prime numbers.A. TrueB. False...
- C Computers and Technology A is an information system that enables users to retrieve data from the Web by using keywords related to their topic of interest....
- C Computers and Technology In what ways can technology help you be more productive? (Select all that apply.) Enables you to create electronic documents that present your ideas clearly and...
- S Social Studies The Taklimakan Desert- seen here- is located A) east of the Gobi Desert B) west of the Indian Ocean south of the Ganges River...
- M Mathematics PLS HELP ASAP For the relation S: {(2, 3), (-1, 4), (1, 6)}. Find the domain and range....
Ответ:
Here is the Encyclopedia class:
public class Encyclopedia extends Book { //class Encyclopedia that inherits from class Book
private String edition; //declare private member variable edition of type String
private int numVolumes; //declare private member variable numVolumes of type int
public void setEdition(String ed) { //mutator method of class that sets the value of edition
edition = ed; } //assigns the value of ed to edition member field
public void setNumVolumes(int numVol) { //mutator method of class that sets the value of numVol
numVolumes = numVol; } //assigns the value of numVolumes to edition member field
public String getEdition() { //accessor method to get the value of edition
return edition; } //returns the current value of edition
public int getNumVolumes() { //accessor method to get the value of numVolumes
return numVolumes; } //returns the current value of numVolumes
public void printInfo() { //method to print edition and number of volumes information on output screen
super.printInfo(); // The super keyword refers to parent class Book objects. It is used to call Book method and to eliminate the confusion between Book class printInfo method and Encyclopedia printInfo method
System.out.println(" Edition: " + edition); //prints edition info
System.out.println(" Number of Volumes: " + numVolumes); } } //prints number of volumes info
Explanation:
The explanation is provided in the attached document.
Ответ: