Starting Out with Java: Early Objects (6th Edition)
6th Edition
ISBN: 9780134462011
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
thumb_up100%
Chapter 9, Problem 23TF
True or False: If a subclass constructor does not explicitly call a superclass constructor, Java will not call any of the superclass’s constructors.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The super keyword is used in a subclass constructor to explicitly control
the superclass constructor that must be invoked before the execution of
the subclass constructor proceeds. *
True
O False
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
Inheritance
The more general class is typically known as the parent class, super class, or base class. The more specific class is typically known as the child
class, sub class, or derived class.
The Java keyword extends allows you to indicate that one class should be the child class of the original parent class. The child will then
inherit everything from the parent class, including variables and methods.
{0}
Online (1)
Main.java x Student.java
public class Main {
1
2
3
4
5
6
Run V
7
8
9
10
11
12
13
14 }
public static void main(String[] args) {
/* Person class example */
Person teacher = new Person();
teacher.setName("Laurel");
System.out.println(teacher);
}
Reid Moseley
X Person.java x
/* Student class example */
Student student = new Student ();
student.setName("Alice");
System.out.println(student);
CONSOLE SHELL
Name: Laurel
Name: Alice
Reset to Template
Open Desktop
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
Automobile Costs Write a program that asks the user to enter the monthly costs for the following expenses incur...
Starting Out with C++ from Control Structures to Objects (8th Edition)
Modify the algorithm that you designed in question 4 so it adds all of the numbers read from the file and displ...
Starting Out with Programming Logic and Design (4th Edition)
Write the first line of the definition for a Poodle class. The class should extend the Dog class.
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Explain what can be done with primary keys to eliminate key ripple effects as a database evolves.
Modern Database Management
These are words that have a special meaning in the programming language. a. punctuation b. programmer-defined n...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
What data type do you use when you want to create a file stream object that can write data to a file?
Starting Out with C++: Early Objects (9th 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
- Part 1 Java Create a UML class diagram for the Circle class as described below: radius: a double PI: a final double initialized with the value 3.14159 The class should have the following methods: a constructor that takes the radius of the circle getRadius – An accessor (getter) for the radius setRadius - A mutator (setter) method for the radius calculateArea - Returns the area of the circle, which is calculated as: area = PI * radius * radius calculateDiameter - Returns the diameter of the circle, which is calculated as: diameter = radius * 2 calculateCircumference - Returns the circumference of the circle, which is calculated as: circumference = 2 * PI * radius Create test data for several different Circle objects and calculate the expected results of calling the various methods. Input Expected Results radius Area Diameter Circumferencearrow_forwardParent Class: Food Write a parent class called Food. A food is described by a name, the number of grams of sugar (as a whole number), and the number of grams of sodium (as a whole number). Core Class Components For the Food class, write: the complete class header the instance data variables a constructor that sets the instance data variables based on parameters getters and setters; use validity checking on the parameters where appropriate a toString method that returns a text representation of a Food object that includes all three characteristics of the food Class-Specific Method Write a method that calculates what percent of the daily recommended amount of sugar is contained in a food. The daily recommended amount might change, so the method takes in the daily allowance and then calculates the percentage. For example, let's say a food had 6 grams of sugar. If the daily allowance was 24 grams, the percent would be 0.25. For that same food, if the daily allowance was 36 grams, the…arrow_forwardThe_ keyword is used in a subclass constructor to explicitly control the superclass constructor that must be invoked before the execution of the subclass constructor proceeds. *arrow_forward
- True or False 1) After a user defines his/her own constructor in a Java class, the default constructor is still available. ___(2) Java supports multiple inheritances directly. ___(3) Some methods in an interface can have method body.arrow_forwardTrue or False A class can implement more than one interface.arrow_forwardvariables are variables that have the same name as variables that have been declared in a superclass and are declared in a subclass, respectively.arrow_forward
- Object Oriented Programming in JAVA You are part of a team writing classes for the different game objects in a video game. You need to write classes for the two human objects warrior and politician. A warrior has the attributes name (of type String) and speed (of type int). Speed is a measure of how fast the warrior can run and fight. A politician has the attributes name (of type String) and diplomacy (of type int). Diplomacy is the ability to outwit an adversary without using force. From this description identify a superclass as well as two subclasses. Each of these three classes need to have a default constructor, a constructor with parameters for all the instance variables in that class (as well as any instance variables inherited from a superclass) accessor (get) and mutator (set) methods for all instance variables and a toString method. The toString method needs to return a string representation of the object. Also write a main method for each class in which that class is…arrow_forward#pyhton programing topic: Introduction to Method and Designing class Method overloading & Constructor overloading ------------------ please find the attached imagearrow_forwardChild Class: Vegetable Write a child class called Vegetable. A vegetable is described by a name, the number of grams of sugar (as a whole number), the number of grams of sodium (as a whole number), and whether or not the vegetable is a starch. Core Class Components For the Vegetable class, write: the complete class header the instance data variables a constructor that sets the instance data variables based on parameters getters and setters; use instance data variables where appropriate a toString method that returns a text representation of a Vegetable object that includes all four characteristics of the vegetableJavaarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
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,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ Data Members; Author: CppNuts;https://www.youtube.com/watch?v=StlsYRNnWaE;License: Standard YouTube License, CC-BY