Question
Question 1: Which of the following is true? Select all that apply. a. Constructors can invoke other methods in the class. b. A class can
Question 1:
Which of the following is true? Select all that apply.
a. Constructors can invoke other methods in the class. |
b. A class can only have one constructor. |
c. Constructors always have the same name as the class. |
d. The compiler always creates a default constructor (a constructor with no arguments) for a class. |
e. Constructors are used to initialize instance variables.
Question 2: Write a class header for a class that would represent a car.
----------------------------------------------------- In the next few questions, write a complete class called Book (described below). A book is described by a title, author, ISBN code (see below), and publication year. ISBN code is a unique 13-digit code assigned to all books. Codes might contain dashes. For example, the code for our textbook is 978-0133807806. Question 3: Write the class header and the instance data variables for the Book class.
Question 4: Write a constructor for the Book class. The constructor should initialize the instance data variables using parameters.
Question 5: Write accessor and mutator (getter and setter) methods. Include validity checking where appropriate.
Question 6: Write a toString method to return a nicely formatted, multi-line description of the book.
Question 7: Write code that would go inside of a main method. The code should create three book objects and invoke at least two methods on each object. Also include a statement to print a text representation of one of the books to the console. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started