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
Concept explainers
Textbook Question
Chapter 10, Problem 9MC
A method in a subclass having the same name as a method in the superclass but a different signature is an example of __________.
- a. overloading
- b. overriding
- c. composition
- d. an error
Expert Solution & Answer
Learn your wayIncludes step-by-step video
schedule06:36
Students have asked these similar questions
Assume that you write a class Student that does not have a declared superclass. You do not write a toString method. Consider the following lines of code:Student st = new Student();String s = st.toString();Will these lines compile? If so, what exactly will happen when you try to execute?
Assume you have a method expecting the superclass's object to be passed as an argument. In this case, if you give it an object of subclass rather than superclass. Is it acceptable? Why or why not? (Write in maximum 5 lines)
I'm learning java in college and I missed one homework assignment. Since then it has been difficult to keep up with homework because they were based on the one I missed.
Here's the prompt:
Design a class Phone with one data member as long phoneNumber. Add constructors, get/set methods to class Phone. Then design a class InternationalPhone as subclass of class Phone, with one extra data member as int countryCode. Add constructors, get/set methods to class InternationalPhone. Write a main program to test these two classes.
(We use netbeans btw)
I can't get any credit for this so there's no rush but I would be very happy to recieve an answer before the end of the semester. Thank you in advance :)
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
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
How is the type declaration of an r value reference distinguished from that of an lvalue reference?
Starting Out with C++: Early Objects (9th Edition)
What is the error in the following structure definition? What is the message your compiler gives for this error...
Problem Solving with C++ (9th Edition)
What clause must you write in the header of a method that performs a file operation?
Starting Out with Java: Early Objects (6th Edition)
What value in an array does the selection sort algorithm look for first? When the selection sort finds this val...
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Write four different Java statements that each add 1 to integer variable x.
Java How To Program (Early Objects)
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
- In Java, Write a line of code that performs each of the following tasks : (a) Call superclass Employee's toString method from subclass Pieceworker's toString method. (b)Specify that class Pieceworker inherits from class Employee. (c) Call superclass Employee's constructor from subclass Pieceworker's constructor - assume that the superclass constructor receives three strings representing the first name, last name and social security number.arrow_forwardwrite a class called OneItemBag ( OneItemBag.java ). This class represents a bag that can hold any single type of object (decided at bag-creation time), and only one item of that type at a time. You may have a zero-parameter constructor if you want one, but you must have the following three features:1. a method that puts an item in the bag (addItem()) which returns whether or not it was successfully added2. a method that removes an item from the bag and returns it (removeItem()), return null if there is no item3. a method to check if an item is in the bag (hasItem()) which returns true or falsearrow_forwardCreate a class called Employee as a a derived class of the class Person. An employee record has an employee's name, address, gender(inherited from the class Person), an ID number whose type is String, an annual salary represented as a single value of type double, and a year the employee started work as a single value of type int. Your class should have a reasonable number of constructors and setter methods, as well as getter methods. Write another class containing a main method to fully test your class definition.arrow_forward
- IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method returning the average number of paintings per artist. You should create a test class which creates 2 Art Gallery objects, then calls your set methods, get methods, toString and equals methods and average paintings per artist for the Art Gallery objects.arrow_forwardCreate a class called Employee as a a derived class of the class Person. An employee record has an employee's name, address, gender(inherited from the class Person), an ID number whose type is String, an annual salary represented as a single value of type double, and a year the employee started work as a single value of type int. Your class should have a reasonable number of constructors and setter methods, as well as getter methods. Create another class containing a main method to fully test your class definition.arrow_forwardCreate a class called Employee as a a derived class of the class Person. An employee record has an employee's name, address, gender(inherited from the class Person), an ID number whose type is String, an annual salary represented as a single value of type double, and a year the employee started work as a single value of type int. Your class should have a reasonable number of constructors and setter methods, as well as getter methods. Create another class containing a main method to fully test your class definition. programming language to be used is javaarrow_forward
- IN JAVA A furniture store specializes in office furniture and sells Office Chairs, Desks and Book Shelves. Customers can buy furniture using the application of the furniture shop. Create a class Furniture having id, finishing/polish, and price provide appropriate methods for the data members provide toString method and a method Buy which simply prints “Buying A Furniture”; as type of furniture is not specified. Next create class Chairs having fabric (String), arms (Boolean), as data members this extends the functionality of Furniture class. Provide appropriate methods for data members, also provide an override method Buy which helps customers buy the chair please note the following1. Arms are optional if customers wants to have armed chair then it will add extra cost of 1000 to the original price of chair otherwise price remains same. 2. User can also change color of polish (options available brown, black and white). Price of black and brown are Rs 2,000 each whereas price of…arrow_forwardIN JAVA Which is true? A. Private members can be accessed by a class user B. A mutator is also known as a getter method C. A mutator may change class fields D. An accessor is also known as a setter methodarrow_forwardANSWER IN JAVA: 3.14 (Date Class) Create a class called Date that includes three instance variables-a month (type int), a day (type int) and a year (type int). Provide a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day and year separated by forward slashes (/). Add a main method to the class that demonstrates class Date's capabilities. STANDARD OUTPUT: Enter·the·month,·day·and·year·in·the·form·XX·XX·XXXX·and·hit·enter:The·Date·object's·state·is:·11/5/1929↵ Enter·a·new·year:The·Date·object's·state·is:·11/5/1978↵ Enter·a·new·day:The·Date·object's·state·is:·11/12/1978↵ Enter·a·new·month:The·Date·object's·state·is:·6/12/1978↵arrow_forward
- FOR JAVA Part I Create a Company class that has at least three properties. Part II Write proper constructor and other methods required for the class (get & set, toString etc.) Part III Write at least 5 different methods considering the applications of Company class. Your methods must handle exceptions. Part IV Write a Test class and use the methods written in Company class.arrow_forwardWhen a method in a subclass overrides a method in superclass, it is still possible to call the overridden method using super keyword. If you write super.func() to call the function func(), it will call the method that was defined in the superclass. You are given a partially completed code in the editor. Modify the code so that the code prints the following text: Hello I am a motorcycle, I am a cycle with an engine. My ancestor is a cycle who is a vehicle with pedals. import java.util.*;import java.io.*; class BiCycle{String define_me(){return "a vehicle with pedals.";}} class MotorCycle extends BiCycle{String define_me(){return "a cycle with an engine.";}MotorCycle(){System.out.println("Hello I am a motorcycle, I am "+ define_me()); //////code hereString temp=define_me(); //Fix this line and code here/////code ends here System.out.println("My ancestor is a cycle who is "+ temp );}}class Solution{public static void main(String []args){MotorCycle M=new MotorCycle();}}arrow_forwardin Java Part 1 : Start by creating a new class called MyPoint that can be initialized with either of these constructors: MyPoint p1 = new MyPoint(); MyPoint p2 = new MyPoint(2.0, 4.0); The two arguments given to the constructor are x (2.0) and y (4.0) co-ordinates. Don’t forget to include getters and setters as these should be private instance variables! Part 2 : Create a toString() instance method that prints out the co-ordinates of the point. Add two instance methods that return the Euclidean distance to another point, or to another (x, y) coordinate. Example: double distance = p2.distance(p1); The Euclidean distance between two points is: d=√x^2 + y^2 You will need to make use of methods from the Math package: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Math.html Test your constructors and the new methods. Part 3 : Create a class method, contains(MyPoint[] points, MyPoint p), that checks if the point p is in the array points and returns a boolean.…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,
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,
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