Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 8.4, Problem 29STQ
Are the two definitions of the constructors given in Listing 8.14 an example of overloading or overriding?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
use java (ArrayList, inheritance, polymorphism, File I/O and basic Java)
Student class:
First, you need to design, code in Java, test and document a base class, Student. The Student class will
have the following information, and all of these should be defined as Private:
A first name (given name)
A last name (family name/surname)
Student number (ID) – an integer number (of type long)
The Student class will have at least the following constructors and methods:
(i) two constructors - one without any parameters (the default constructor), and one with
parameters to give initial values to all the instance variables of Student.
(ii) only necessary set and get methods for a valid class design.
(iii) a reportGrade method, which you have nothing to report here, you can just print to the screen
a message “There is no grade here.”. This method will be overridden in the respective child
classes.
(iv) an equals method which compares two student objects and returns true if they…
Based on the following Diagram answer the below questions.
a. What is the Definition of Polymorphism?
b. Extract from the above UML Diagram an example of Overridden method? Explain the meaning of Overridden?
c. Extract from the above UML Diagram above an example of Overloading method? Explain the meaning of overloading?
d. Write an array declaration that is expected to hold up to 10 objects of type Student and Employee?
Use abstract classes and pure virtual functions to design classes to manipulate various types ofaccounts. For simplicity, assume that the bank offers three types of accounts: savings, checking, andcertificate of deposit, as described next.Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimumbalance and a lower interest rate and another that requires a minimum balance and has a higherinterest rate.Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthlyservice charge, limited check writing, no minimum balance, and no interest; another with no monthlyservice charge, a minimum balance requirement, unlimited check writing and lower interest; and a thirdwith no monthly service charge, a higher minimum requirement, a higher interest rate, and unlimitedcheck writing.Certificate of deposit (CD): In an account of this type, money is left for some time, and these accountsdraw higher interest rates than…
Chapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 8.1 - Prob. 1STQCh. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Can a derived class directly access by name a...Ch. 8.1 - Can a derived class directly invoke a private...Ch. 8.1 - Prob. 6STQCh. 8.1 - Suppose s is an object of the class Student. Base...Ch. 8.2 - Give a complete definition of a class called...Ch. 8.2 - Add a constructor to the class Student that sets...Ch. 8.2 - Rewrite the definition of the method writeoutput...
Ch. 8.2 - Rewrite the definition of the method reset for the...Ch. 8.2 - Can an object be referenced by variables of...Ch. 8.2 - What is the type or types of the variable(s) that...Ch. 8.2 - Prob. 14STQCh. 8.2 - Prob. 15STQCh. 8.2 - Consider the code below, which was discussed in...Ch. 8.2 - Prob. 17STQCh. 8.3 - Prob. 18STQCh. 8.3 - Prob. 19STQCh. 8.3 - Is overloading a method name an example of...Ch. 8.3 - In the following code, will the two invocations of...Ch. 8.3 - In the following code, which definition of...Ch. 8.4 - Prob. 23STQCh. 8.4 - Prob. 24STQCh. 8.4 - Prob. 25STQCh. 8.4 - Prob. 26STQCh. 8.4 - Prob. 27STQCh. 8.4 - Prob. 28STQCh. 8.4 - Are the two definitions of the constructors given...Ch. 8.4 - The private method skipSpaces appears in the...Ch. 8.4 - Describe the implementation of the method drawHere...Ch. 8.4 - Is the following valid if ShapeBaSe is defined as...Ch. 8.4 - Prob. 33STQCh. 8.5 - Prob. 34STQCh. 8.5 - What is an advantage of having the main...Ch. 8.5 - What Java construct allows us to define and...Ch. 8 - Consider a program that will keep track of the...Ch. 8 - Implement your base class for the hierarchy from...Ch. 8 - Draw a hierarchy for the components you might find...Ch. 8 - Suppose we want to implement a drawing program...Ch. 8 - Create a class Square derived from DrawableShape,...Ch. 8 - Create a class SchoolKid that is the base class...Ch. 8 - Derive a class ExaggeratingKid from SchoolKid, as...Ch. 8 - Create an abstract class PayCalculator that has an...Ch. 8 - Derive a class RegularPay from PayCalculator, as...Ch. 8 - Create an abstract class DiscountPolicy. It should...Ch. 8 - Derive a class BulkDiscount from DiscountPolicy,...Ch. 8 - Derive a class BuyNItemsGetOneFree from...Ch. 8 - Prob. 13ECh. 8 - Prob. 14ECh. 8 - Create an interface MessageEncoder that has a...Ch. 8 - Create a class SubstitutionCipher that implements...Ch. 8 - Create a class ShuffleCipher that implements the...Ch. 8 - Define a class named Employee whose objects are...Ch. 8 - Define a class named Doctor whose objects are...Ch. 8 - Create a base class called Vehicle that has the...Ch. 8 - Create a new class called Dog that is derived from...Ch. 8 - Define a class called Diamond that is derived from...Ch. 8 - Prob. 2PPCh. 8 - Prob. 3PPCh. 8 - Prob. 4PPCh. 8 - Create an interface MessageDecoder that has a...Ch. 8 - For this Programming Project, start with...Ch. 8 - Modify the Student class in Listing 8.2 so that it...Ch. 8 - Create a JavaFX application that uses a TextField...Ch. 8 - Prob. 10PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What do you call a program that translates a high-level language program into a separate machine language progr...
Starting Out with Python (4th Edition)
Why is it useful for a programmer to have some background in language design, even though he or she may never a...
Concepts of Programming Languages (11th Edition)
Why should you indent the statements in the body of a loop?
Starting Out with Programming Logic and Design (4th Edition)
The while loop is this type of loop. a. pretest b. posttest c. prefix d. postfix
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
How can functions make the development of multiple programs faster?
Starting Out with Python (3rd Edition)
Payroll Class Design a Payroll class that has fields for an employees name, ID number, hourly pay rate, and num...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
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
- Implement a nested class composition relationship between any two class types from the following list: Advisor Вook Classroom Department Friend Grade School Student Teacher Tutor Write all necessary code for both classes to demonstrate a nested composition relationship including the following: a. one encapsulated data member for each class b. inline default constructor using constructor delegation for each class c. inline one-parameter constructor for each class d. inline accessors for all data members e. inline mutators for all data membersarrow_forwardUse C++ Create a class called Fruit. Add one member variables name. Add only one getter function for the name. The get function returns name. Implement a constructor that expects name value and assigns it to the member variable. This class doesn't have an empty constructor. Create a subclass of Fruit named CitrusFruit. The CitrusFruit class has two member variables weight and color. Add a constructor which expects weight and name and color.Pass name to the base constructor and set weight and color to it's member variable. Write a program that has an array of 3 Fruits, and an array of 3 CitrusFruits. Feel free to give the name , weight and color to the object as your choice. Use loops to print out the array properties to the terminal screen.arrow_forwardPlease solve in C++ Do the exercise 8 - 11.10 (Account Inheritance Hierarchy), this is only a portion of the description of the program. The rest of it can be found in the exercises section of the book. Create an inheritance hierarchy that a bank might use to represent customers' bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). (THE REST OF THE DESCRIPTION OF THIS CHALLENGE IS IN THE BOOK.) Please see exercise 8 - 11.10 below 8. 11.10 ( Account Inheritance Hierarchy) Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their…arrow_forward
- Code in JAVA and please see attached images on specifications The Inheritance hierarchy is as follows: (Be sure to create this hierarchy correctly and efficiently; taking advantage of inheritance, polymorphism and exception handling concepts discussed in previous modules) A company pays its personnel on a weekly basis. The personnel are of 4 types: FixedWeekly personnel are paid a fixed amount regardless of the number of hours workedByTheHour personnel are paid by the hour and receive overtime pay for all hours worked in excess of 40PercentOfSales personnel are paid a percentage of their salesFixedWeeklyPercentOfSales personnel receive a fixed amount plus a percentage of their sales.All variables are private, thus all of them will have public getters and setters Create a class called Personnel. This class will represent the general concept of all personnel. All 4 types of personnel are considered Personnel. FixedWeeklyPercentOfSales personnel are considered to be PercentOfSales…arrow_forwardCan a class be a super class and a sub-class at the same time? Give example.arrow_forwardCode in JAVA and please see attached images on specifications The Inheritance hierarchy is as follows: (Be sure to create this hierarchy correctly and efficiently; taking advantage of inheritance, polymorphism and exception handling concepts discussed in previous modules) A company pays its personnel on a weekly basis. The personnel are of 4 types: FixedWeekly personnel are paid a fixed amount regardless of the number of hours workedByTheHour personnel are paid by the hour and receive overtime pay for all hours worked in excess of 40PercentOfSales personnel are paid a percentage of their salesFixedWeeklyPercentOfSales personnel receive a fixed amount plus a percentage of their sales.All variables are private, thus all of them will have public getters and setters Create a class called Personnel. This class will represent the general concept of all personnel. All 4 types of personnel are considered Personnel. FixedWeeklyPercentOfSales personnel are considered to be PercentOfSales…arrow_forward
- Use inheritance and classes to represent a deck of playing cards. Create a Card class that stores the suit (Clubs, Diamonds, Hearts, Spades) and name (e.g., Ace, 2, 10, Jack) along with appropriate accessors, constructors, and mutators. Next, create a Deck class that stores a vector of Card objects. The default constructor should create objects that represent the standard 52 cards and store them in the vector. The Deck class should have functions to:■ Print every card in the deck.■ Shuffle the cards in the deck. You can implement this by randomly swapping every card in the deck.■ Add a new card to the deck. This function should take a Card object as aparameter and add it to the vector.■ Remove a card from the deck. This removes the first card stored in the vector and returns it.■ Sort the cards in the deck ordered by name. Next, create a Hand class that represents the cards in a hand. Hand should be derived from Deck. This is because a hand is like a specialized version of a deck; we…arrow_forwardSolve the problem in C++ (Extend MyPoint) In Programming Exercise 9.4, the MyPoint class was created to model a point in a two-dimensional plane. The MyPoint class has the properties x and y that represent x- and y-coordinates, two getter functions for x and y, and the function for returning the distance between two points. Create a class named ThreeDPoint to model a point in a three-dimensional space. Let ThreeDPoint be derived from MyPoint with the following additional features: - A data field named z that represents the z-coordinate.- A no-arg constructor that constructs a point with coordinates (0, 0, 0).- A constructor that constructs a point with three specified coordinates.- A constant getter function that returns the z value.- A constant distance(const MyPoint&) function to return the distance between this point and the other point in the three-dimensional space. Draw the UML diagram for the classes involved. Implement the classes. Write a test program that creates two…arrow_forwardCan we make constructor STATIC?arrow_forward
- Java- Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.arrow_forwardWrite a class Person that has attributes of id, name and address. It has a constructor to initialize, a member function to input and a member function to display data members. Create another class Student that inherits Person class. It has additional attributes of rollnumber and marks. It also has member function to input and display its data members. Write a simple C++ code as I am a beginner.arrow_forwardEncountering Fairies ( c++ with separate header and cpp files for each fairy Functionality You will define a small hierarchy of fairy classes. In main(), you will then instantiate (i.e., create) several fairy objects (from the derived classes ONLY), but no more than 5. When the user encounters a fairy, the fairy will state his/her name and ask what the user wants. In response, the user may: Ask for a wish, Offer to help the fairy, or Say goodbye to the fairy. The user will continue to interact with the fairy until the user chooses the final option, saying goodbye to the fairy. Once the user says goodbye, the game moves on to the next fairy. After the user has encountered all of the fairies, the game is over and the user's points total is displayed. Specifications All interaction will occur through standard input and standard output. Fairy (base class; NEVER instantiated): Must state his/her name and a greeting Must ask what the user wants Must respond to requests for wishes…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
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