Ask Question
22 January, 14:22

Look at the following partial class definition, then respond to the questions that follow it: public class Book { private String title; private string author; private string publisher; private int copiesSold; } Write a constructor for this class. The constructor should accept an argument for each of the fields.

+1
Answers (1)
  1. 22 January, 17:26
    0
    I will code in Java.

    public class Book {

    private String title;

    private String author;

    private String publisher;

    private int copiesSold;

    //the constructor method accepts the parameters for each field.

    public Book (String title, String author, String publisher, int copiesSold) {

    //each parameter is set to each field of the class.

    this. title = title;

    this. author = author;

    this. publisher = publisher;

    this. copiesSold = copiesSold;

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Look at the following partial class definition, then respond to the questions that follow it: public class Book { private String title; ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers