Concept explainers
In an inheritance relationship, the ___________ is the general class.
a. subclass
b. superclass
c. slave class
d. child class
In an inheritance relationship, the superclass is referred as “General class”.
Hence, the correct answer is option is “B”.
Explanation of Solution
Inheritance:
In python, it is possible to construct a new class that inherits the members of an existing class, which is referred as “inheritance”.
“is a” relationship in inheritance:
In python, if one object is a specialized kind of another object, then there should be an “is a” relationship between those objects. This is used to create the “is a” relationship among several classes.
For example:
- A truck is a vehicle.
- A circle is a shape.
Super class and sub class:
In python, the inheritance concept involves two classes. They are superclass and subclass.
- A superclass is also referred as “general class” or “base class” and a subclass is referred as “specialized class” or “derived class”.
- The sub class is an extended kind of the superclass. This means a subclass can inherit the attributes and class member functions from the superclass without rewriting them in the subclass.
- Extra methods can be added in the subclass, which implies the specialized kind of the superclass.
Explanation for the incorrect options:
In inheritance, a subclass is referred as “specialized class” or “derived class”.
Hence, option “A” is wrong.
In inheritance, slave class is not present.
Hence, option “C” is wrong.
In inheritance, a subclass is referred as “specialized class” or “derived class” or child class.
Hence, option “D” is wrong.
Want to see more full solutions like this?
Chapter 11 Solutions
Starting Out with Python (4th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Absolute Java (6th Edition)
Starting Out with C++: Early Objects
Database Concepts (8th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- Create class employee with properties ID, name, salary, write accessor, mutator &constructor for the class. In main create three objects of class & find the employee with the highestsalary.arrow_forwardWhich type of inheritance is illustrated by the following code? class student{ public: int marks; };class topper: public student { public: char grade; };class average{ public: int makrs_needed; };class section: public average{ public: char name[10]; };class overall: public average{ public: int students; }; i Single levelii Multilevel and single leveliii Hierarchicaliv Hierarchical and single levelarrow_forwardCreate a classstudent which includes parameters roll_no, name and address and consider as super class.Then create sub class test with parameters marl1, mark2, mark3 and mark4. Then create another sub class result with parameters total_marks, percentage and grade. Apply multi level inheritance. Here Student class is the super class for test class and test class is super class of resultclass. Implement a java application in which obtain the details roll_no, name, address, marl1, mark2, mark3 and mark4 from user side andthen print total_marks, percentage and grade.Studentàtestàresultarrow_forward
- Create an abstract super class called Employee with the following attributes: Use JavaDoc comments in the Parent and Child Classes only but use @author for the driver name : String and the following methods getter and setter for the one attribute two constructors an abstract method called getPay() equals() toString() Create a sub class of Employee called SalaryEmployee with the following attribute yearlyPay : double and the following methods getter and setter for the one attribute two constructors getPay() that returns the yearlyPay divided by 52 equals() toString() Create a sub class of Employee called HourlyEmployee with the following attributes: hoursWorked : double payrate : double and the following methods getters and setters for the two attributes two constructors getPay() that returns the weekly pay (multiply hoursWorked by payrate - overtime included and 1.5 times payrate for hours > 40) equals() toString() Create a sub class of Employee called SalesEmployee with the…arrow_forwardWrite a program in java that contain a class named office, data members include area and noOfEmployees. Two classes named regionalOffice and headQuarters are derived from office. regionalOffice contain managerName and location as data members while headQuarters contain CEO as data member. Data members of child class must be protected. Write input method, display method, a parametric constructor initializing all data members(both parent and child class). Use chaining in above all. Also define all accessor and mutator methodsarrow_forwardQ2. Write a class Bank that has the following data members –Account Holder name (ah_name[]) –Account number (ac_number) •Must unique, system generates automatically, and must starting from 100 (Hints: Use another static variable and assign that variable to ac_number) –Balance in the account (ac_balance) •The class has the following member functions –A constructor to initialize the data members –Input() to takes name from the user –Deposit(parameter) to deposits balance in the account •Must accept parameter (The amount to deposit) –Withdraw(parameter) to withdraws balance after checking •Must accept parameter (The amount to withdraw) –Display() to show the name, account number, and balancearrow_forward
- Write a class named Vehicle with vehicleType, manufactureYear(int) and cost(double) as private data fields. [Hint: VehcleType could be "truck", "4WD", "Bus"] . Add a constructor with any two parameters of the superclass. Write a class named Car which inherits the Vehicle class. Add a non-static private string variable called companyName. Add a constructor in the subclass and a toString() method that prints the Car's data fields in the order VehicleType, manufactureYear, companyName [Hint: Add a toString( ) method in the superclass as well]. Create objects of Vehicle and Car class. Can the object of Vehicle class be stored in an object of Car Class? If yes, write the code. If No, Explain why? ***Student Instruction *** You need to write the complete code as mentioned below: i) The main class with necessary codes. ii) The subclass with necessary codes.iii) The Test class with necessary codes.arrow_forwardAssume that you have created a class named MyClass. The header of the MyClass constructor can be ____________. public MyClass() public MyClass (double d) Either of these can be the constructor header. Neither of these can be the constructor header.arrow_forwardUsing classes, design an online address book to keep track of the names, addresses, phone numbers, and dates of birth of family members, close friends, and certain business associates. Your program should be able to handle a maximum of 500 entries. Define a class addressType that can store a street address, city, state, and ZIP code. Use the appropriate functions to print and store the address. Also, use constructors to automatically initialize the member variables. Define a class extPersonType using the class personType (as defined in Example 10-10, Chapter 10), the class dateType (as designed in this chapters Programming Exercise 2), and the class addressType. Add a member variable to this class to classify the person as a family member, friend, or business associate. Also, add a member variable to store the phone number. Add (or override) the functions to print and store the appropriate information. Use constructors to automatically initialize the member variables. Define the class addressBookType using the previously defined classes. An object of the type addressBookType should be able to process a maximum of 500 entries. The program should perform the following operations: Load the data into the address book from a disk. Sort the address book by last name. Search for a person by last name. Print the address, phone number, and date of birth (if it exists) of a given person. Print the names of the people whose birthdays are in a given month. Print the names of all the people between two last names. Depending on the users request, print the names of all family members, friends, or business associates.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning