Starting Out with Java: Early Objects (6th Edition)
6th Edition
ISBN: 9780134462011
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
thumb_up100%
Chapter 9, Problem 13MC
Program Description Answer
If a particular class implements an interface, then the class must provide all the non-default methods that are specified in the interface with the same signatures.
Hence, the correct answer is option “B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Design/code/test a Java program containing an abstract the class absWelcome. This class should
contain:
1. A public abstract void method (you name it) that is empty
2. A public regular method (you name it) that prints "Welcome to "
Next, create a subclass clsHello that extends absWelcome. This class should contain:
• A public regular method (you name it) that prints "Java Programming"
Finally, inside the Main class create an object (you name it) from the clsHello class. Use this new
object reference to:
1. Output "Welcome to " from the abstract class
2. Output "Java Programming" from the subclass
Your output should resemble that shown below
>sh -c javac -classpath
-type f-name '*.java')
java -classpath :targe
Welcome to
Java Programming
True or False
a.
If you do not write a constructor for a class, java will
supply a default constructor.
b.
Java does not allow constructors to be overloaded.
Abstract methods must have a void return type.
d. All classes have a default equals (Object) method even if
their programmer didn't write one for it.
You can override a static method defined in a superclass.
A method can have at most one return statement.
g.
A method cannot return a Wrapper class reference.
h. The reserved word super can be used to access a constructor
in a parent class.
i. Object is an abstract class.
e.
f.
True or False
A class can implement more than one interface.
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...
Knowledge Booster
Similar questions
- An interface can have : instance variables. only method headings without implementation. some methods with implementation. only one constructor.arrow_forwardYou cannot instantiate an interface but you can do so to an abstract class. True Falsearrow_forwardThis is object oriented programmingarrow_forward
- 1. 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_forwardWhat method is automatically executed whenever a new instance of the class, which the method belongs to, has been instantiated? a. encapsulation b. abstraction c. polymorphismarrow_forwardDefine a java Name class with attributes: String firstname, middle name, lastname. Include the following methods: - A constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. - getter and setter methods for all attributes - override toString method Define a class called DebitCard. A debit card has a card number, Name and balance. a) Include a constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. b) Include getters/setters for all attributes. c) Add the following member functions: float inquireBalance() float depositCash(float amount) //increases the balance with amount boolean withdrawCash(float amount) // returns true if sufficient amount is available for withdrawal and decreases the balance by amount float interest(float rate) //calculates the interest rate incurred. Assume the parameter rate is considered as…arrow_forward
- Define a java Name class with attributes: String firstname, middle name, lastname. Include the following methods: - A constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. - getter and setter methods for all attributes - override toString method Define a class called DebitCard. A debit card has a card number, Name and balance. a) Include a constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. b) Include getters/setters for all attributes. c) Add the following member functions: float inquireBalance() float depositCash(float amount) //increases the balance with amount boolean withdrawCash(float amount) // returns true if sufficient amount is available for withdrawal and decreases the balance by amount float interest(float rate) //calculates the interest rate incurred. Assume the parameter rate is considered as…arrow_forwardPick the incorrect statement: O A class can implement more than one interface O A class can extend more than one classes O An interface can extend more than one interfaces O An interface cannot extend a classarrow_forward- Creates a class Teacher with two attributes: name and specialty. a. Add a constructor able to create a Teacher; b. Add the methods getName and getSpeciality; c. Add the method display able to display the attributesarrow_forward
- JAVAarrow_forwardi. When inheriting an Interface from an Interface, the newly created Interface should include all the methods of super Interface. ii. When inheriting a Class from an Interface, the newly created Class should include all the methods of super Interface. iii. Abstract classes have both abstract and non-abstract methods while Interfaces have only abstract methods. Which sentence or sentences is/are wrong? Lütfen birini seçin: a. Only ii b. All c. Only iii d. i and ii e. Only iarrow_forwardSoftware Requirements: • Latest version of NetBeans IDE • Java Development Kit (JDK) 8 Procedure: 1. Create a public class named Monday. This class shall contain the main method. 2. Define an interface (without a modifier) named Alarm. This interface shall contain two (2) void methods named setAlarm() and showAlarm(). The setAlarm() method has a String parameter named time. 3. Add two (2) classes without modifiers named Weekday (abstract) and Monday. 4. For the Weekday class, implement the Alarm interface. Leave this class empty. 5. Set Weekday as the parent of Monday. Import Scanner from java.util and LocalTime from java.time. For showAlarm(), add these two (2) statements: LocalTime alarm = LocalTime .parse(time); LocalTime now = LocalTime.now(); Explanation: parse() converts String to time, while now() obtains the current time. 7. The output shall ask the user to enter the time for the alarm. If the time entered is past the current time, then display "Alarm is set for tomorrow!";…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher: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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning