Starting Out with Java: Early Objects (6th Edition)
6th Edition
ISBN: 9780134462011
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
thumb_up100%
Chapter 9, Problem 16MC
Abstract classes cannot ___________.
- a. be used as superclasses
- b. have abstract methods
- c. be instantiated
- d. have fields
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create 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…
Animal:
Create a class Animal and Add a protected data member named id of integer type.
• Add get/set methods for id data member in Animal class with public access. Also provide default constructor this should initialize id to 0.
• Also provide parameterized constructor and toString method.
• Add an abstract method tellAboutSelf method to Animal class with public access
• Add another abstract method speak method to Animal class.
Reptile, Bird, Mammal
Next create the three child classes which extends form Animal class.
• Add a default constructor to each of the above created class. The constructor should initialize the id data member id, Reptile, Bird and Mammal, to 1, 2 and 3 respectively also it display a message “(class Name)’s default constructor”. E.g. for Bird it says “Bird’s default constructor”.
• Add a parameterized constructor to each of the above created class. The constructor should initialize the id data member, Reptile, Bird and Mammal, to the specified id passed to the…
__________ allows a base class reference variable to reference a derived class object. a. Polymorphism b. Inheritance c. Generalization d. Specialization
Chapter 9 Solutions
Starting Out with Java: Early Objects (6th Edition)
Ch. 9.1 - Here is the first line of a class declaration....Ch. 9.1 - Look at the following class declarations and...Ch. 9.1 - Class B extends class A. (Class A is the...Ch. 9.2 - Prob. 9.4CPCh. 9.2 - Look at the following classes: public class Ground...Ch. 9.3 - Under what circumstances would a subclass need to...Ch. 9.3 - How can a subclass method call an overridden...Ch. 9.3 - If a method in a subclass has the same signature...Ch. 9.3 - If a method in a subclass has the same name as a...Ch. 9.3 - Prob. 9.10CP
Ch. 9.4 - When a class member is declared as protected, what...Ch. 9.4 - What is the difference between private members and...Ch. 9.4 - Why should you avoid making class members...Ch. 9.4 - Prob. 9.14CPCh. 9.4 - Why is it easy to give package access to a class...Ch. 9.6 - Look at the following class definition: public...Ch. 9.6 - When you create a class, it automatically has a...Ch. 9.7 - Recall the Rectangle and Cube classes discussed...Ch. 9.8 - Prob. 9.19CPCh. 9.8 - If a subclass extends a superclass with an...Ch. 9.8 - What is the purpose of an abstract class?Ch. 9.8 - If a class is defined as abstract, what can you...Ch. 9.9 - Prob. 9.23CPCh. 9.9 - Prob. 9.24CPCh. 9.9 - Prob. 9.25CPCh. 9.9 - Prob. 9.26CPCh. 9.9 - Prob. 9.27CPCh. 9.9 - Prob. 9.28CPCh. 9 - In an inheritance relationship, this is the...Ch. 9 - In an inheritance relationship, this is the...Ch. 9 - This key word indicates that a class inherits from...Ch. 9 - A subclass does not have access to these...Ch. 9 - This key word refers to an objects superclass. a....Ch. 9 - In a subclass constructor, a call to the...Ch. 9 - The following is an explicit call to the...Ch. 9 - A method in a subclass that has the same signature...Ch. 9 - A method in a subclass having the same name as a...Ch. 9 - These superclass members are accessible to...Ch. 9 - Prob. 11MCCh. 9 - With this type of binding, the Java Virtual...Ch. 9 - Prob. 13MCCh. 9 - Prob. 14MCCh. 9 - Prob. 15MCCh. 9 - Abstract classes cannot ___________. a. be used as...Ch. 9 - You use the __________ operator to define an...Ch. 9 - Prob. 18MCCh. 9 - Prob. 19MCCh. 9 - You can use a lambda expression to instantiate an...Ch. 9 - True or False: Constructors are not inherited.Ch. 9 - True or False: in a subclass, a call to the...Ch. 9 - True or False: If a subclass constructor does not...Ch. 9 - True or False: An object of a superclass can...Ch. 9 - True or False: The superclass constructor always...Ch. 9 - True or False: When a method is declared with the...Ch. 9 - True or False: A superclass has a member with...Ch. 9 - True or False: A superclass reference variable can...Ch. 9 - True or False: A subclass reference variable can...Ch. 9 - True or False: When a class contains an abstract...Ch. 9 - True or False: A class may only implement one...Ch. 9 - True or False: By default all members of an...Ch. 9 - // Superclass public class Vehicle { (Member...Ch. 9 - // Superclass public class Vehicle { private...Ch. 9 - // Superclass public class Vehicle { private...Ch. 9 - // Superclass public class Vehicle { public...Ch. 9 - Write the first line of the definition for a...Ch. 9 - Look at the following code, which is the first...Ch. 9 - Write the declaration for class B. The classs...Ch. 9 - Write the statement that calls a superclass...Ch. 9 - A superclass has the following method: public void...Ch. 9 - A superclass has the following abstract method:...Ch. 9 - Prob. 7AWCh. 9 - Prob. 8AWCh. 9 - Look at the following interface: public interface...Ch. 9 - Prob. 1SACh. 9 - A program uses two classes: Animal and Dog. Which...Ch. 9 - What is the superclass and what is the subclass in...Ch. 9 - What is the difference between a protected class...Ch. 9 - Can a subclass ever directly access the private...Ch. 9 - Which constructor is called first, that of the...Ch. 9 - What is the difference between overriding a...Ch. 9 - Prob. 8SACh. 9 - Prob. 9SACh. 9 - Prob. 10SACh. 9 - What is an. abstract class?Ch. 9 - Prob. 12SACh. 9 - When you instantiate an anonymous inner class, the...Ch. 9 - Prob. 14SACh. 9 - Prob. 15SACh. 9 - Employee and ProductionWorker Classes Design a...Ch. 9 - ShiftSupervisor Class In a particular factory, a...Ch. 9 - TeamLeader Class In a particular factory, a team...Ch. 9 - Essay Class Design an Essay class that extends the...Ch. 9 - Course Grades In a course, a teacher gives the...Ch. 9 - Analyzable Interface Modify the CourseGrades class...Ch. 9 - Person and Customer Classes Design a class named...Ch. 9 - PreferredCustomer Class A retail store has a...Ch. 9 - BankAccount and SavingsAccount Classes Design an...Ch. 9 - Ship, CruiseShip, and CargoShip Classes Design a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Finish the program that takes a word as a command-line argument and looks up the word to see whether it is in t...
Programming in C
Describe what a compiler does with a programs source code.
Starting Out with C++: Early Objects (9th Edition)
In pseudocode, write the first line of the definition for a Poodle class. The class should extend the Dog class...
Starting Out with Programming Logic and Design (4th Edition)
Modify the Product_T table by adding an attribute QtyOnHand that can be used to track the finished goods invent...
Modern Database Management
Repeat the calorie-counting program described in Programming Project 8 from Chapter 2. This time ask the user t...
Java: An Introduction to Problem Solving and Programming (7th 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
- Create a class Animal and Add a protected data member named id of integer type. Add get/set methods for id data member in Animal class with public access. Also provide default constructor this should initialize id to 0. Also provide parameterized constructor and toString method. Add an abstract method tellAboutSelf method to Animal class with public access Add another abstract method speak method to Animal class. Reptile, Bird, Mammal Next create the three child classes which extends form Animal class. Add a default constructor to each of the above created class. The constructor should initialize the id data member id, Reptile, Bird and Mammal, to 1, 2 and 3 respectively also it display a message “(class Name)’s default constructor”. E.g. for Bird it says “Bird’s default constructor”. Add a parameterized constructor to each of the above created class. The constructor should initialize the id data member, Reptile, Bird and Mammal, to the specified id passed to the constructor also it…arrow_forwardQ1: Java programming to Write a complete abstract class named Store with the following members: 1. Item number 2. quantity: number of items 3. abstract method TotalPrice which calculate and returns the total price as quantity*price. 4. Aconstructor which initialize the item number and quantity. Part B: Write a class named Items which inherits from the previous class (Store) and contains the following members: 1. itemName: The name of the item. 2. price: Item price 3. A constructor to initialize the properties. 4. A method Bill() which prints the item name, price, quantity, and total price. Part C: Write a class which contains the method Main and create an instance of the class Items and call the method Bill properly.arrow_forward77255 Polymorphism - abstract class BankingAccount class. Create an application with an abstract class called Account with an abstract method calculateInterest, derive the following three classes from Account class 1. SBAccount 2. DAccount 3. FDAccount Implement the abstract method in these classes; Invoke these methods from the main method using the reference of BankingAccount classarrow_forward
- Write a complete abstract class named Store with the following members: 1. Item number 2. quantity: number of items 3. abstract method TotalPrice which calculate and returns the total price as quantity*price. 4. Aconstructor which initialize the item number and quantity. Part B: Write a class named Items which inherits from the previous class (Store) and contains the following members: 1. itemName: The name of the item. 2. price: Item price 3. A constructor to initialize the properties. 4. A method Bill() which prints the item name, price, quantity, and total price. Part C: Write a class which contains the method Main and create an instance of the class Items and call the method Bill properly.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_forwardCreate a class called Person. From this class, inherit another class called student. Assume suitable data members and member functions for these two classes. In both the classes, define the __str__ function and demonstrate method overriding. in python programmingarrow_forward
- Fill the gap: The________declares that a derived class is allowed to override a method.arrow_forwardIf ParentClass is a Java class and we want the derived classes to have access to all the members of ParentClass, then we used the __?___ access specifier. a) public b) private c) protected d) inheritarrow_forwardProgramming Language = Python 1. Employee and ProductionWorker Classes Write an Employee class that keeps data attributes for the following pieces of information: • Employee name • Employee number Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: • Shift number (an integer, such as 1, 2, or 3) • Hourly pay rate The workday is divided into two shifts: day and night. The shift attribute will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write the appropriate accessor and mutator methods for each class. Once you have written the classes, write a program that creates an object of the ProductionWorker class and prompts the user to enter data for each of the object’s data attributes. Store the data in the object and then use the object’s accessor methods to retrieve it and display it on the…arrow_forward
- Design a new Triangle class that extends the abstract GeometricObject class: Draw the UML diagram for the classes Triangle and GeometricObject Implement the Triangle class Write a test program that prompts the user to enter three sides of the triangle, a color, and a Boolean value to indicate whether the triangle is filled: The program should create a Triangle object with these sides and set the color and filled properties using the input The program should display the area, perimeter, color, and true or false to indicate whether it is filled or notarrow_forwardCreate a class Student with following instance private variables and member functions: Variable: id (int), name (String), Major (String) Constructor: overloaded constructor Methods: Accessor/Mutator (Setter/Getters), toString Create class College with following instance variable and member function: Variable: SIZE (final and int), Student array example: Student[] student; Constructor: overloaded which take one input size and this will be the value of SIZE viable and Student array size. Methods: addStudent(id, name, major) method: This method will create and add student object to the student array and when the array gets full the method will give an error message saying that you cannot add more students searchStudent(id) method: This method uses sequential search algorithm to find a student using student id in the student array. If the student is found it will return the student object otherwise it will return null. Create class StudentSearch with the main method and the main method…arrow_forwardQuestion 1 O instance A class that passes its attributes and methods on to another class is referred to as a(n). subclass inheritance esc base class SAVE & CONTINUE Report an issue with this question FI F2 9.0 F3 1 2 ODD DOD F4 3 O Mark this question 4 FS 5 3..arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- 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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
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