Concept explainers
Suppose the class SportsCar is a derived class of a class Automobile. Suppose also that the class Automobile has private instance named speed, manufacturer, and numberOfCylinders. Will an object of the class SportsCar have instance variables named speed, manufacturer, and numberOfCylinders?
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
C++ How to Program (10th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Web Development and Design Foundations with HTML5 (8th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
- 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_forwardTable 1: Class Attributes name, registration number, engine number, chassis number, city of registrat make and model, color, the date of the registration, price, the date of arrival of car to the dealership, type of the vehicle, and whether the car is sold or not. dealer's name, dealer's id, dealer's address, and the dealer's phone number. dealer object also keeps track of the cars that the dealer has. A person has a name, address, phone number and e-mail address. Car Dealer Personarrow_forwardConsider a base class named Employee and its derived classes HourlyEmployee and PermanentEmployee while taking into account the following criteria.• Employee class has two data fields i.e. a name (of type string) and specific empID (of type integer)• Both classes (HourlyEmployee and PermanentEmployee) have an attribute named hourlyIncome• Both classes (HourlyEmployee and PermanentEmployee) have three-argumentconstructor to initialize the hourlyIncome as well as data fields of the base class• Class HourlyEmployee has a function named calculate_the_hourly_income to calculate the income of an employee for the actual number of hours he or she worked. One hour income is Rs. 150 • Similarly, PermanentEmployee class has function named calculate_the_income to calculate the income of an employee that gets paid the salary for exact 240 hours, no matter how many actual hours he or she worked. Again, one hour salary is Rs. 150.Implement all class definitions with their respective constructors to…arrow_forward
- The State Patrol Ticket-Processing System (Revisited 2. List the classes that would be involved in the use cases and decide which class should be responsible for collaborating with the other classes for the use case Record a traffic ticket. Consider some possibilities: A Driver object should be responsible for recording his/her ticket, the Officer object should be responsible for recording the ticket that he or she writes, and a Ticket object should be responsible for recording itself.arrow_forwardSuppose that class Child extends class Parent, and that Parent does not explicitly extend another class. Suppose also that Child has THREE constructors and Parent has TWO constructors. When creating a Child object, Child c = new Child(...), what is the minimum and maximum number of constructors being called in total?arrow_forwardCreate an abstract class named capstone with necessary abstract methods in Package 1 and define classes like Inhouse, PAT_Internship and NonPAT_Internship with required data members in sub package 1. Get a choice from student and based on the input from student, create parent reference to hold the respective child object and print the details in Package 2.arrow_forward
- Please written by hand solution In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition, the shift supervisor earns a yearly bonus when their shift meets production goals. Write a private ShiftSupervisor class that is a subclass of the Employee class from problem 1. The ShiftSupervisor class should keep a data attribute for annual salary and data attribute for the annual production bonus that a shift supervisor has earned. Demonstrate the class by writing a program that uses a ShiftSupervisor object (create an object and display all the attributes). PYTHON ONLYarrow_forwardjust mention the Anwsers. Explanation is not needed. Thank youarrow_forwardQUESTION 2 In object oriented programming, inheritance improves code readability and maintenance by allowing new classes to re-use existing classes. Use inheritance to solve the following problem: A: A Car is a Vehicle and has a name, a max_speed value and a number_of_cylinders attribute that specifies the number of cylinders in the car's engine. - Add accessor and mutator methods to get and set the values of the class attributes. - Attributes of the car objects are initialized at the time when the object is created. - When a car object is printed, its name, max_speed and number_of_cylinders are shown. B: An Airplane is also a Vehicle and has a name, a max_speed value and a number_of engines attribute that specifies the number of jet engines the airplane has. - Add accessor and mutator methods to get and set the values of the class attributes. - Attributes of the airplane objects are initialized at the time when the object is created. - When an airplane object is printed, its name,…arrow_forward
- Class A is the parent class, while classes B and C are the subclasses of A. Both B and C contain several features and techniques that are equivalent to one another; nevertheless, the implementations of some of their methods are quite different between the two. Explain what kind of class A will be using logic; is it going to be a concrete class, an abstract class, or an interface?arrow_forwardUML diagram analysis: refer to the following UML diagram of the Loan Class. a) How many instance variables does the TV class have? b) How many methods that return a value does the TV class have? c) How many static methods does the TV class have? d) How many constructors does the TV class have? e) How many defaults data fields does the TV class have?arrow_forwardProblem B Now we are going to use the design pattern for collecting objects. We are going to create two classes, a class AmazonOrder that models Amazon orders and a class Item that models items in Amazon orders. An item has a name and a price, and the name is unique. The Item class has a constructor that takes name and price, in that order. The class also has getters and setters for the instance variables. This is the design pattern for managing properties of objects. The setName() method should do nothing if the parameter is the empty string, and the setPrice() method should do nothing if the parameter is not positive. The class also has a toString() method that returns a string representation for the item in the format “Item[Name:iPad,Price:399.99]”. For simplicity, we assume an Amazon order can have at most 5 items, and class AmazonOrder has two instance variables, an array of Item with a length of 5 and an integer numOfItems to keep track of the number of items in the…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage