Concept explainers
Suppose the class SportsCar is a derived class of a class Automobile, and suppose also that the class Automobile has public method accelerate and addGas. Will an object of the class SportsCar have methods named accelerate and addGas? If so, do these method perform the exact same actions in the class SportsCar as in the class Automobile?
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Degarmo's Materials And Processes In Manufacturing
Management Information Systems: Managing The Digital Firm (16th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- NOTE: READ CAREFULLY Design a class named Person and a subclasses named Employee. Make Teacher a subclass of Employee. A Person has a name, address, and e-mail address. An Employee has an office, salary. A Teacher has office hours and a subject they teach. They also have a tenure status. Define the tenure status as a constant. The tenure status is either Senior or Junior, and is represented as an integer, where Senior is equal to 1, and Junior is equal to 2. Each class should have a Default constructor, and a constructor that accepts all arguments. There should be appropriate calls to the superclass within the constructors. Each class should also have getters and setters for each member variable. Each class should have a toString method. Note: You do NOT need to run this in a test program. Just create the classes as indicated above.arrow_forwardImplement the Seller class as a derived class of Person class. Create the seller.h and seller.cppfiles for this class. The Seller class contains additional data members that hold a seller’s:o average star rating received from the buyers, ando total number of items sold.These data should be accessible by its derived classes. (should these data be private, public, orprotected?) The following methods are included in the seller class:• A default constructor and a copy constructor• A constructor that receives all of the data for a seller.(for the constructors, make sure to call the base class constructor as appropriate)• Appropriate get and set functions for the new data in this class• print() – overrides the base class print() to print the base class data and print all additionalseller data with appropriate messages. Make sure to call the base class print to print thebase class data.• read() – overrides the base class read() to read the base class data and reads all additionalseller data…arrow_forwardDefine a class named Employee. This class should extend the Person class from the previous question. The class should have a constructor, which takes the name, age, employer (String) and salary (int) as parameters (in that order). The first two parameters should be passed to the constructor of the superclass and the value of the last two parameters should be stored in instance variables. The class should define the methods, getSalary which returns the salary of the employee and getEmployer which returns the name of the employer. Any methods from the previous question that need to be overridden should be overridden! Use super and instanceof as appropriate. I.e., for the following methods you should be able to call the method in the superclass for specific situations (e.g. the compareTo method in the superclass can be called if you receive anything other than an Employee, and this also holds for the equals method). The toString method only needs to append details and as such can also…arrow_forward
- Make a class Person, with instance variable name, age, and gender. Make a class Employee inheritfrom Person, with extra data for salary, and hiring date. Make another class Student inherit from Person,with data for program name, level (undergraduate/graduate), and program year. Supply required methods forthe superclass and the subclasses. Make a subclass Manager from Employee, with bonus salary, andoverride the corresponding method(s). Provide toString method for the Employee class and its subclass,Manager, such that it returns employee name, type of the employment, and salary. For instance if you createan object, manager1, from Manager class, with name=”John Smith” and annual salary of $125,000 and bonusweekly bonus of $200, and then write a print statement like System.out.println(manager1); , the output willbe:John Smith, Manager, Salary = $125,000/year, Weekly bonus = $200arrow_forwardWrite the classes as shown in the following class diagram. Add a tester that asks the user for a cat, dog and a BigDog then call all of their methods. Note that Cat and Dog inherit from the abstract class Animal and BigDog inherits from Dog.arrow_forwardAssume B is a subclass of A. Which of the statements about the following assignment is false? A a = new B(); We can assign anything to variable a that has a subtype of B. We can call on a any method defined in A. We can call on a any method defined in B. We can assign anything to variable a that has a subtype of A.arrow_forward
- Which of the following are true? If we derive a class from an abstract class, we can select which methods we choose to implement in our derived class. Abstract classed cannot have concrete methods. We can declare an instance of an abstract class. All of the above statements are false.arrow_forwardImplement all the classes using Java programming language from the given UML Class diagram. Note: This problem requires you to submit just two classes: Person.java, User.java, Coach.java. Do NOT include "public static void main()" method inside all of these classes.arrow_forwardMake a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of type string. Supply a method tostring that prints the manager's name, department, and salary. Make a class Executive inherit from Manager. Supply appropriate tostring methods for all classes. Supply a test program that tests these classes and methods.arrow_forward
- An airport van shuttles passengers between the terminal and the parking garage. After 4 trips, the tank is empty, and the van needs to drive to the gas station. After it has been refilled, it will drive to the terminal. The behavior of the car depends on two states: its location (terminal, garage, or gas station), and the tank level (empty or not). Complete the following class. The constructor yields a van in the garage with a full tank.arrow_forwardIn the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The implementation of Employee class is given (Note: no getter methods are provided, so you are not able to access instance variables through getter methods in the subclass). The skeleton of the Manager class definition is given. Complete the constructor method, and the toString method for the subclass (see the details below). public class Employee { private String name; private double salary; // Make an employee with a given name and salary. public Employee(String aName, double aSalary) { name = aName; salary = aSalary; } // Provide a string description of an employee. public String toString() { return "Name: " + name + "\tSalary: " + salary; } } public class Manager extends Employee { private String department; // Make a manager with a given name, salary, and department. public Manager(String name, double salary, String department) { // put your code below } // Provide a string…arrow_forwardIn the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The implementation of Employee class is given (Note: no getter methods are provided, so you are not able to access instance variables through getter methods in the subclass). The skeleton of the Manager class definition is given. Complete the constructor method, and the toString method for the subclass (see the details below). public class Employee {_private String name; private double salary; // Make an employee with a given name and salary. public Employee(String aName, double aSalary) { name salary = aSalary; } // Provide a string description of an employee. public String toString() { return "Name: "tSalary: "+ salary; } } public class Manager extends Employee { private String department; // Make a manager with a given name, salary, and department. public Manager(String name, double salary, String department) { // put your code below } // Provide a string toString() { // put your code…arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning