Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 6, Problem 2AW
Look at the following partial class definition, and then respond to the questions that follow it:
public class Book
{
private String title;
private String author;
private String publisher;
private int copiesSold;
}
- a. Write a constructor for this class. The constructor should accept an argument for each of the fields.
- b. Write accessor and mutator methods for each field.
- c. Draw a UML diagram for the class, including the methods you have written.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Practice with writing a program that contains three classes:
Ship
CruiseShip
CargoShip Classes
Design a Ship class with the following members:
A field for the name of the ship (a string)
A field for the year that the ship was built (a string)
A constructor that accepts two arguments for the two fields, and appropriate accessors and mutators
A toString method that returns a string with the ship’s name and the year it was built
Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members:
A field for the maximum number of passengers (an int)
A constructor that accepts three arguments for the three fields and appropriate accessors and mutators
A toString method that overrides the toString method in the base class. The CruiseShip class’s toString method should return a string with only the ship’s name and the maximum number of passengers.
Design a CargoShip class that extends the Ship class. The CargoShip class should have the…
46. It is an advanced concept in Object Oriented Programming that is achieved by separating the use of a method from its implementation.
Abstraction
Polymorphism
None of the Choices
Classes
Give an explanation for the answer. Thank you
Build a UML Diagram for Programming Exercise 2
Chapter 6 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 6.1 - What does an object use its fields for?Ch. 6.1 - Prob. 6.2CPCh. 6.1 - How is a class like a blueprint?Ch. 6.1 - You have programs that create Scanner, Random, and...Ch. 6.1 - Prob. 6.5CPCh. 6.1 - What values do reference variables hold?Ch. 6.1 - Prob. 6.7CPCh. 6.2 - You hear someone make the following comment: A...Ch. 6.2 - Prob. 6.9CPCh. 6.2 - When a variable is said to reference an object,...
Ch. 6.2 - A string literal, such as Joe, causes what type of...Ch. 6.2 - Prob. 6.12CPCh. 6.2 - Prob. 6.13CPCh. 6.2 - Prob. 6.14CPCh. 6.2 - Prob. 6.15CPCh. 6.2 - What is a stale data item?Ch. 6.3 - Assume that r1 and r2 are variables that reference...Ch. 6.4 - How is a constructor named?Ch. 6.4 - What is a constructors return type?Ch. 6.4 - Prob. 6.20CPCh. 6.7 - Prob. 6.21CPCh. 6.7 - What is a methods signature?Ch. 6.7 - Look at the following class: public class...Ch. 6.7 - How many default constructors may a class have?Ch. 6.9 - Prob. 6.25CPCh. 6.9 - When designing an object-oriented application, who...Ch. 6.9 - How do you identify the potential classes in a...Ch. 6.9 - What are a classs responsibilities?Ch. 6.9 - What two questions should you ask to determine a...Ch. 6.9 - Will all of a classs actions always be directly...Ch. 6 - This is a collection of programming statements...Ch. 6 - A class is analogous to a(n) _______. a. house b....Ch. 6 - An object is a(n) ________. a. blueprint b....Ch. 6 - This is a class member that holds data. a. method...Ch. 6 - This key word causes an object to be created in...Ch. 6 - This is a method that gets a value from a classs...Ch. 6 - This is a method that stores a value in a field or...Ch. 6 - When the value of an item is dependent on other...Ch. 6 - This is a method that is automatically called when...Ch. 6 - When a local variable has the same name as a...Ch. 6 - This is automatically provided for a class if you...Ch. 6 - Prob. 12MCCh. 6 - Prob. 13MCCh. 6 - A classs responsibilities are __________. a. the...Ch. 6 - True or False: The new operator creates an...Ch. 6 - True or False: Each instance of a class has its...Ch. 6 - True or False: When you write a constructor for a...Ch. 6 - True or False: A class may not have more than one...Ch. 6 - True or False: To find the classes needed for an...Ch. 6 - Find the error in the following class: public...Ch. 6 - Prob. 2FTECh. 6 - The following statement attempts to create a...Ch. 6 - Find the error in the following class: public...Ch. 6 - Find the error in the following class: public...Ch. 6 - Design a class named Pet, which should have the...Ch. 6 - Look at the following partial class definition,...Ch. 6 - Consider the following class declaration: public...Ch. 6 - Look at the following description of a problem...Ch. 6 - The bank offers the following types of accounts to...Ch. 6 - Assume that you are writing an application that...Ch. 6 - What is the difference between a class and an...Ch. 6 - A contractor uses a blueprint to build a set of...Ch. 6 - What is an accessor method? What is a mutator...Ch. 6 - is it a good idea to make fields private? Why or...Ch. 6 - If a class has a private field, what has access to...Ch. 6 - Prob. 6SACh. 6 - Assume a program named MailList.java is stored in...Ch. 6 - Why are constructors useful for performing...Ch. 6 - Under what circumstances does Java automatically...Ch. 6 - What do you call a constructor that accepts no...Ch. 6 - Prob. 11SACh. 6 - How does method overloading improve the usefulness...Ch. 6 - Employee Class Write a class named Employee that...Ch. 6 - Car Class Write a class named Car that has the...Ch. 6 - Personal Information Class Design a class that...Ch. 6 - Retail Item Class Write a class named RetailItem...Ch. 6 - Payroll Class Design a Payroll class that has...Ch. 6 - TestScores Class Design a TestScores class that...Ch. 6 - Circle Class Write a Circle class that has the...Ch. 6 - Temperature Class Write a Temperature class that...Ch. 6 - Days in a Month Write a class named MonthDays, The...Ch. 6 - A Game of Twenty-One For this assignment, you will...Ch. 6 - Freezing and Boiling Points The following table...Ch. 6 - SavingsAccount Class Design a SavingsAccount class...Ch. 6 - Deposit and Withdrawal Files Use Notepad or...Ch. 6 - Patient Charges Write a class named Patient that...Ch. 6 - Dice Game Write a program that uses the Die class...Ch. 6 - Roulette Wheel Colors On a roulette wheel, the...Ch. 6 - Coin Toss Simulator Write a class named Coin. The...Ch. 6 - Tossing Coins for a Dollar For this assignment you...Ch. 6 - Fishing Game Simulation For this assignment, you...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
When a file that already exists is opened in append mode, the file's existing contents are erased.
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
In Exercises 61 through 66, rewrite the statements using augmented assignment operators. Assume that each varia...
Introduction To Programming Using Visual Basic (11th Edition)
What effect does work material hardness have on the metal removal rate in ECM?
Degarmo's Materials And Processes In Manufacturing
Write a summary list of the problem-solving steps identified in the chapter, using your own words.
BASIC BIOMECHANICS
Here are some instructions in English. Translate each of them into Vole machine language. a. LOAD register numb...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Fill in the blanks in each of the following: A(n) is not required if you always refer to a class its fully qual...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Library Information System Design and Testing Library Item Class Design and TestingDesign a class that holds the Library Item Information, with item name, author, publisher. Write appropriate accessor and mutator methods. Also, write a tester program(Console and GUI Program) that creates three instances/objects of the Library Items class. Extending Library Item Class Library and Book Classes: Extend the Library Item class in (1) with a Book class with data attributes for a book’s title, author, publisher and an additional attributes as number of pages, and a Boolean data attribute indicating whether there is both hard copy as well as eBook version of the book. Demonstrate Book Class in a Tester Program (Console and GUI Program) with an object of Book class.arrow_forwardDesign a class named Computer that holds the make, model , and amount of memory of a computer. Include methods to set values for each data field, and include a method that displays all the values for each field. Create the UML diagram ( class diagram) and write the pseudocode that define the classarrow_forwardis a construct that defines objects of the same type. A class An object A method A data fieldarrow_forward
- The behaviour of the instances present of a class inside a method is defined by.arrow_forwardStatic variables can... ...can be accessed even without creating an object of that class. ...only be accessed by static methods. ...not be accessed using class prefix. ...not be inherited.arrow_forwardExplain why you would need both public and private members in a class.arrow_forward
- In JavaScript, a constructor needs to link an object to other functions so that methods are performed only on the object that calls them. (a) True (b)Falsearrow_forwardExplain the advantages of passing this data to a method rather than the current class object directly.arrow_forwardYou need a method to avoid accidental corruption of class fields.arrow_forward
- 3) Design the classes based on the UML diagram given below. You must pay attention to the classes and their relationship as well as the variables and the methods in the classes. You can set an initial position for the shape on the coordinate plane (e.g. 50,50 for x and y respectively), your move() method should modify the position, your area() method should calculate the area for the for the calling class, and your resize() method should modify the lengths, radius and the points(for the triangle) of the caller class. You can put your own values for the initialization. Shape position: int move) resize() area() Rectangle width: int height: int area() Circle Triangle points: List area( radius: float area( Square width: int area()arrow_forwardUML diagram analysis: refer to the following UML diagram of the Loan Class. a) How many instance variables does the TV class have? b) How many methods that return a value does the TV class have? c) How many static methods does the TV class have? d) How many constructors does the TV class have? e) How many defaults data fields does the TV class have?arrow_forwardCLASS NAME List the instance variables in the constructor. List the methods in the class. - indicates private CLASS NAME List the instance variables in the constructor. List the methods in the class. The second row of the UML diagram lists the instance variables in the constructor. For example -name: string o o name is the variable name o string is the data type of name + indicates public o getName is the method name o o string is the return data type Java.util. The third row of the diagram lists the methods in the class. For example, +getName(): string empty parenthesie indicate nothing is sent to the method.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY