Starting Out with Java: From Control Structures through Objects (6th Edition)
6th Edition
ISBN: 9780133957051
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 10, Problem 14MC
When a class implements an interface, it must __________.
- a. overload all of the methods listed in the interface
- b. provide all of the nondefault methods that are listed in the interface, with the exact signatures and return types specified
- c. not have a constructor
- d. be an abstract class
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
1. Create an interface OnlineQuiz with the following details:
Member variables:
totalMarks=10
Member Methods:
· nQuestions(): An abstract method that calculates and return the number of questions. Defined in subclass.
· display(): An abstract method that displays all details. Defined in a subclass.
2. Create a class Staff that inherits OnlineQuiz with the following details:
Member variables:
· staffD // id of the staff string type
· staffName // Name of the staff string type
· nMCQ // Number of MCQ type questions int type
· nTF // Number of true/false type questions int type
· nMatch // Number of match type questions int type
Member Methods:
· Define the parameterized constructor to set the member variables.
· Define the method nQuestions(): which calculate and return the total number of questions.
Total number of question= nMCQ + nTF +…
This is object oriented programming
Create an interface named Playable that defines a method play requiring no return value. Play just displays the string “Play me.” Create a class named Instrument that implements playable that contains a private member name but does not implement the play of Playable.
a. define setter and getter for name
b. define a constructor that accepts a String name argument to be assigned to the name attribute of the class
c. override equals of the object for this class
d. override toString of an object for this class
3. Implement a concrete subclass of an instrument named Guitar.
a. Create a constructor similar to the default constructor provided by the system. See to it that the superclass object is created.
b. See to it that the abstract method is also implemented
c. override equals of the object for this class
d. override toString of the object for this class
Chapter 10 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Ch. 10.1 - Here is the first line of a class declaration....Ch. 10.1 - Look at the following class declarations and...Ch. 10.1 - Class B extends class A. (Class A is the...Ch. 10.2 - Prob. 10.4CPCh. 10.2 - Look at the following classes: public class Ground...Ch. 10.3 - Under what circumstances would a subclass need to...Ch. 10.3 - How can a subclass method call an overridden...Ch. 10.3 - If a method in a subclass has the same signature...Ch. 10.3 - If a method in a subclass has the same name as a...Ch. 10.3 - Prob. 10.10CP
Ch. 10.4 - When a class member is declared as protected, what...Ch. 10.4 - What is the difference between private members and...Ch. 10.4 - Why should you avoid making class members...Ch. 10.4 - Prob. 10.14CPCh. 10.4 - Why is it easy to give package access to a class...Ch. 10.6 - Look at the following class definition: public...Ch. 10.6 - When you create a class, it automatically has a...Ch. 10.7 - Recall the Rectangle and Cube classes discussed...Ch. 10.8 - Prob. 10.19CPCh. 10.8 - If a subclass extends a superclass with an...Ch. 10.8 - What is the purpose of an abstract class?Ch. 10.8 - If a class is defined as abstract, what can you...Ch. 10.9 - Prob. 10.23CPCh. 10.9 - Prob. 10.24CPCh. 10.9 - Prob. 10.25CPCh. 10.9 - Prob. 10.26CPCh. 10.9 - Prob. 10.27CPCh. 10.9 - Prob. 10.28CPCh. 10 - In an inheritance relationship, this is the...Ch. 10 - In an inheritance relationship, this is the...Ch. 10 - This key word indicates that a class inherits from...Ch. 10 - A subclass does not have access to these...Ch. 10 - This key word refers to an objects superclass. a....Ch. 10 - In a subclass constructor, a call to the...Ch. 10 - The following is an explicit call to the...Ch. 10 - A method in a subclass that has the same signature...Ch. 10 - A method in a subclass having the same name as a...Ch. 10 - These superclass members are accessible to...Ch. 10 - Prob. 11MCCh. 10 - With this type of binding, the Java Virtual...Ch. 10 - This operator can be used to determine whether a...Ch. 10 - When a class implements an interface, it must...Ch. 10 - Prob. 15MCCh. 10 - Prob. 16MCCh. 10 - Abstract classes cannot ___________. a. be used as...Ch. 10 - You use the __________ operator to define an...Ch. 10 - Prob. 19MCCh. 10 - Prob. 20MCCh. 10 - You can use a lambda expression to instantiate an...Ch. 10 - True or False: Constructors are not inherited.Ch. 10 - True or False: in a subclass, a call to the...Ch. 10 - True or False: If a subclass constructor does not...Ch. 10 - True or False: An object of a superclass can...Ch. 10 - True or False: The superclass constructor always...Ch. 10 - True or False: When a method is declared with the...Ch. 10 - True or False: A superclass has a member with...Ch. 10 - True or False: A superclass reference variable can...Ch. 10 - True or False: A subclass reference variable can...Ch. 10 - True or False: When a class contains an abstract...Ch. 10 - True or False: A class may only implement one...Ch. 10 - True or False: By default all members of an...Ch. 10 - // Superclass public class Vehicle { (Member...Ch. 10 - // Superclass public class Vehicle { private...Ch. 10 - // Superclass public class Vehicle { private...Ch. 10 - // Superclass public class Vehicle { public...Ch. 10 - Write the first line of the definition for a...Ch. 10 - Look at the following code, which is the first...Ch. 10 - Write the declaration for class B. The classs...Ch. 10 - Write the statement that calls a superclass...Ch. 10 - A superclass has the following method: public void...Ch. 10 - A superclass has the following abstract method:...Ch. 10 - Prob. 7AWCh. 10 - Prob. 8AWCh. 10 - Look at the following interface: public interface...Ch. 10 - Prob. 1SACh. 10 - A program uses two classes: Animal and Dog. Which...Ch. 10 - What is the superclass and what is the subclass in...Ch. 10 - What is the difference between a protected class...Ch. 10 - Can a subclass ever directly access the private...Ch. 10 - Which constructor is called first, that of the...Ch. 10 - What is the difference between overriding a...Ch. 10 - Prob. 8SACh. 10 - Prob. 9SACh. 10 - Prob. 10SACh. 10 - What is an. abstract class?Ch. 10 - Prob. 12SACh. 10 - When you instantiate an anonymous inner class, the...Ch. 10 - Prob. 14SACh. 10 - Prob. 15SACh. 10 - Employee and ProductionWorker Classes Design a...Ch. 10 - ShiftSupervisor Class In a particular factory, a...Ch. 10 - TeamLeader Class In a particular factory, a team...Ch. 10 - Essay Class Design an Essay class that extends the...Ch. 10 - Course Grades In a course, a teacher gives the...Ch. 10 - Analyzable Interface Modify the CourseGrades class...Ch. 10 - Person and Customer Classes Design a class named...Ch. 10 - PreferredCustomer Class A retail store has a...Ch. 10 - BankAccount and SavingsAccount Classes Design an...Ch. 10 - Ship, CruiseShip, and CargoShip Classes Design a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What are the advantages in implementing a language with a pure interpreter?
Concepts Of Programming Languages
Write a program like that of the previous exercise that converts from kilograms and grams into pounds and ounce...
Problem Solving with C++ (10th Edition)
These are symbols or words that perform operations on one or more operands. a. punctuation b. programmer-define...
Starting Out with Java: From Control Structures through Data Structures (4th 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)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Big data Big data describes datasets with huge volumes that are beyond the ability of typical database manageme...
Management Information Systems: Managing The Digital Firm (16th Edition)
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
- Write a program named SalespersonDemo that instantiates objects using classes named Real EstateSalesperson and GirlScout. Demonstrate that each object can use a SalesSpeech() method appropriately. Also, use a MakeSale() method two or three times with each object, and display the final contents of each objects data fields. First, create an abstract class named Salesperson. Fields include first and last names; the Salesperson constructor requires both these values. Include properties for the fields. Include a method that returns a string that holds the Salespersons full name—the first and last names separated by a space. Then perform the following Create two child classes of Salesperson: Real EstateSalesperson and Girl Scout. The Real EstateSalesperson class contains fields for total value sold in dollars and total commission earned (both of which are initialized to 0), and a commission rate field required by the class constructor. The Girl Scout class includes a field to hold the number of boxes of cookies sold, which is initialized to 0. Include properties for every field. Create an interface named ISell able that contains two methods: SalesSpeech() and MakeSale(). In each Real EstateSalesperson and Girl Scout class, implement SalesSpeech() to display an appropriate one- or two-sentence sales speech that the objects of the class could use. In the Real Estatesalesperson class, implement the MakeSale() method to accept an integer dollar value for a house, add the value to the Real EstateSalespersons total value sold, and compute the total commission earned. In the Girl Scout class, implement the MakeSale() method to accept an integer representing the number of boxes of cookies sold and add it to the total field.arrow_forwardinheritance in javaarrow_forwardin C++arrow_forward
- öclhäll daila Declare an abstract class named A that contains: 1-A private static integer variable called C 2-A private integer variable called id 3-A constructor with no argument that sets id = 4-A public method Area() that returns 1.2 5-An abstract method getName () id + C Declare a derived class from A called B that contains: 1- Two integer variables x and y 2- A constructor to initialize the fields of B class 3- Two accessor methods getx() and gety() that return the values of - An overridden method getName() that returns the name of the class and y reclare a derived class from B called Circle that contains: - A protected double variables radius - A constructor to initialize the fields of Circle - An overridden method getName() that returns the name of the class - An overridden method Area() that calculates and B classes and returns the of Circle ite a test program to invoke the different methods declared in B and Circle classes areaarrow_forwardin javaarrow_forwardIn java language on netbeans design a console application that will print the game sales for a particular game in 2021. Use an abstract class named Games that contains variables to store the game name, game genre and the total sales. Create a constructor that accepts the game name, game genre and the total game sales as parameters. In this class also create get methods for the variables. The Games class must implement an iGames interface that contains the following: public interface iGames { public void printSales(); public String getGame(); public String getGameGenre(); public int getGameSales(); } Create a subclass called Game Sales that extends the Games class. The Games Sales class must contain a constructor to accept the game name, game genre and total game sales as parameters. Then, write code for the Print Sales method, which prints the game sales report for 2021. Finally, write a Use Games class to instantiate the Games Sales class.arrow_forward
- 1. Create a class RealEstate with the following details: Member variables: buildingID // building ID string type buildingName // name of the building string type Member Methods: · Parameterized constructor to set the member variables. · rentPrice(): An abstract method which calculates and return the rent. Defined in a subclass. · display(): To display the name & ID of the building. 2. Create a class Apartment that inherits RealEstate with the following details: Member variables: · noOfrooms // number of rooms int type · noOfBathroom // number of bath rooms int type · furnished // To check whether the furnished or not Boolean type Member Methods: · Define the parameterized constructor to set the member variables and also call the constructor of the superclass · Define the method rentPrice() which calculate and return the rent as given below:…arrow_forwardCreate an abstract super class called Employee with the following attributes: Use JavaDoc comments in the Parent and Child Classes only but use @author for the driver name : String and the following methods getter and setter for the one attribute two constructors an abstract method called getPay() equals() toString() Create a sub class of Employee called SalaryEmployee with the following attribute yearlyPay : double and the following methods getter and setter for the one attribute two constructors getPay() that returns the yearlyPay divided by 52 equals() toString() Create a sub class of Employee called HourlyEmployee with the following attributes: hoursWorked : double payrate : double and the following methods getters and setters for the two attributes two constructors getPay() that returns the weekly pay (multiply hoursWorked by payrate - overtime included and 1.5 times payrate for hours > 40) equals() toString() Create a sub class of Employee called SalesEmployee with the…arrow_forwardDesign a class named Author with the following members: A field for the author’s name (a String) A field for the author’s year of birth (an int) One or more constructors and appropriate accessor and mutator methods A toString method that displays the author’s info as: Author: Mary Shelley (1797) Save the file as Author.java. Next, create an abstract class named Book with the following members: A field for the book title (a String) A field for the book author (a reference to an Author object) A field for the book price (a double) A constructor that requires the title and author Get methods for the title, author, and price An abstract method named setPrice A toString method that displays the book’s title, author’s info, and price as: Frankenstein Author: Mary Shelley (1797) Price: $23.95 Save the file as Book.java. Create Fiction and NonFiction child classes of Book. Each must include a setPrice method that sets the price for all Fiction books to $23.95 and for all NonFiction books…arrow_forward
- Step 2 ShapesDemo.cs 1 using static System.Console; 2 class ShapesDemo 3 { static void Main() Create a Rectangle is a GeometricFigure 4 whose area is { // Your code here } 8 } determined by multiplying width by height. 7 Create a Square is a Rectangle in which the width and height are the same. Provide a constructor that accepts both height and width, forcing them to be equal if they are not. Provide a second constructor that accepts just one dimension and uses it for both height and width. The Square class uses the Rectangle 's ComputeArea() method. Create a Triangle is a GeometricFigure whose area is determined by multiplying the width by half the height. In the ShapesDemo class , after each object is created, pass it to a method that accepts a GeometricFigure argument in which the figure's data is displayed. Change some dimensions of some of the figures, and pass each to the display method again.arrow_forwardWrite a Java program that implements the following classes: Show - name: String - timesWatched: int - rate: double - maxRate: int =5 + Show() + Show(name: String) + getName(): String + setName(name:String):void + getRate(): double + getTimesWatched(): int + getMaxRate(): int + updateRate(): void + toString(): String Movie Series - duration: int - productionYear: int + Movie() + Movie(name: String, duration: int, productionYear:int) + toString(): String + getDuration(): int + getProductionYear(): int - numOfEpisodes: int episodeDuration: int + Series() + Series(name: String, numOfEpisodes:int, episodeDuration: int) + toString():String + getNumOfEpisodes(): int + getEpisodeDuration(): int In the Show class: - The timesWatched and rate must be initialized to zero. - The no-arg constructor reads the name from the user. - The Show(name: String) constructor initializes the data field name with the value of the passed parameter пате. - The updateRate method reads the user rate and re-computes…arrow_forward1. Create abstract class Pet , which is the abstract super class of all animals.1. Declare an integer attribute called legs, which records the number of legs for this animal.2. Define a constructor that initializes the legs attribute.3. Declare an abstract method eat.4. Declare a concrete method walk that prints out something about how the animals walks (include the number of legs).2. Create the Dog class that implements Pet class.1. This class must include a String attribute to store the name and food of the pet2. Define a default constructor that calls the super class constructor to specify that all dogs have 4 legs and name.3. override the eat and walk method.3. Create the Cat class that Implements Pet class.1. This class must include a String attribute to store the name of the pet, and a string to save food .2. Define a constructor that takes one String parameter that specifies the cat's name. This constructor must also call the super class constructor to specify that all cats have…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,
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher: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,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY