Concept explainers
To find the correct option that can be used as a reliable way to find which class is a base class and which is a derived class.
b. try saying the two class names together.
Explanation of Solution
Explanation:
Classes can be derived from other classes in Java, as in other object-oriented
A reliable way that will help to find which of the two classes is the base class and which is a subclass is by try saying the two class names together.
By saying the names of both base class and derived class, one should check which class is containing more generalized features and which is not. A class that contains more generalized features should be considered as the base class and the other one should be considered as the derived one.
For example: Consider two classes Birds and Pigeon. If we call the names of both, surely, the Birds class will contain more generalized features instead of the Pigeon class. So, the Birds class will be a base class and the Pigeon class will be the derived one.
Conclusion:
Therefore, the correct option is option b. try saying the two class names together.
Want to see more full solutions like this?
Chapter 10 Solutions
EBK JAVA PROGRAMMING
- Create a class BeautyProduct with name, color, brand. Provide Constructors, getters, setters and also write toString method. Now create a class Lipstick which extends the class BeautyProduct as Lipstick is-a Beauty Product it has totalVolume, remainingVolume, price, texture (gloss, matt) as private data members. Provide Constructors, getters, setters and an apply() method whenever this method is called a beauty item is applied and its volume decreases by 10.This should also check that volume must not be zero if it then u have to throw exception. Also write toString method which prints all details like name, color, brand, price, texture and volume. Create another class foundation having totalVolume, remainingVolume, price, texture (liquid, cake) and lastingTime (number of hours foundation remain intact on face and does not crease) as private data members. This also extends the base class i.e. BeautyProduct. Provide Constructors, getters, setters and an apply() method whenever this…arrow_forwardusing c++ oop !!! kindly need help asap. Implement the shape, rectangle, and square classes with components as shown and the following functionality: Each constructor and destructor prints a message to the screen that it is being called in each class implement the area() method that calculates the area of the figure (for the Shape class you can return 0) Example Constructor shape: Rectanleeeeeee Rectangle constructor 232.5 Rectanleeeeeee Eeeeeeee Rectangle destructor Shape destructor Constructor shape: Squareeeee Rectangle constructor Square constructor Squareeeee AAAaaaa 105.165 Square destructor Rectangle destructor Shape destructor // main.cpp : Defines the entry point for the application.// #include "main.h"using namespace std; int main(void) {{rectangle rec("Rectanleeeeeee", 10, 23.25);std::cout << rec.area() << std::endl;std::cout << rec.get_name() << std::endl;rec.set_name("Eeeeeeee");std::cout << rec.get_name() << std::endl;} {square…arrow_forwardCreate a class MyTime which has the datamembers as follows: 1. hour: integer (1 to 12)2. minute: integer (0 to 59)3. second: integer (0 to 59)4. pm: bool variable. True means PM time and false means AM time. Implement a default constructor, a parameterized constructor and a copy constructor. Write set and get functions for all the four members of the class. Overload these operators: 1. Extraction operator >> : Prompt the user for hours, minutes, seconds and for am/pm and initialize the structure. Left operand istream object and right operand MyTime2. Assignment = : Assign the right object to the left object. Both operands are of type MyTime.3. Insertion << : Print the time in the format HH:MM SS PM. Left operand of type ostream and right operand of type MyTime. this in c++.arrow_forward
- Create a base class with two methods. In the first method, call thesecond method. Inherit a class and override the second method.Create an object of the derived class, upcast it to the base type, andcall the first method. Explain what happens.arrow_forwardTest time left: 01:48:45 Q3. Write a Java program to implement the concept of run time polymorphism through method overriding with the following scenario. There are three music companies Tips, Zee and T series. These companies use a super class Music, where there is a constructor for initializing music and play() method to play music. Create subclasses Tips, Zee and Tseries that overrides a play() method in the super class and add some new functionality to it. You can use print statement in the body of the constructor and method of the class.arrow_forwardNovice: How can i access a main class objects from outside the function? / Better Alternative? If i have 4 Student objects how can i print the information for the specific object given one parameter about the class, like the students Idnumber. What i came up with was making a checkId void function that takes the user input and runs an if else chain checking if the Id belongs to student 1-4 then printing the details of that classes object with the void function print. ideally i would want the if-else chain in the checkId function to call the print( student1-4) class object but im not sure how to properly do that. i dont think this is the best way to go about it, if you have any recommendations or alternatives please help me out.arrow_forward
- Part I Write an interface and abstract class for the Electronic that would be used for an electronic store. Part II Write at least two classes corresponding to different types of Electronics. Part III Write a Test class in order to show different functionalities (methods) of the classes written in Part II. Note: Do not compress your files, submit only java files. Note: Do not forget to justify your answers with comments.arrow_forwardYou need 5 java classes and these include Netflix Class (Parent class of Movie and TVShow class) Movie Class TVShow Class Test/TestDriver Class Database Class Please read the questions carefully. TestDriver is given for the other image.arrow_forward1. Create a class Employee with parameters name, id, designation, and basicSalary. Use appropriate datatypes and access specifiers. Use default constructor to create objects of employee. Write methods toset and get the values of parameters of employee. Write methods to find total salary of employee andto display the complete details of employee along with total salary. Create another class TestEmployeewhich creates array of n number of employees, uses appropriate set methods to set the values ofparameters of every employee. Display the details of each employee. (Total salary = basic salary + 80%of basic salary)arrow_forward
- Want in detailarrow_forwarddayType Class We will be working on a project that designs a class calendarType, so that a client program can use this class to print a calendar for any month starting Jan 1. 1900. An example of the calendar for September 2019 is: September 2019 Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 We will develop several classes which will work together to create a calendar. The first of these classes is called dayType which will manipulate a day of the week. The class dayType will store a day, such as Sun for Sunday. The class should be able to perform the following operations on an object of type dayType: a. Set the day. b. Print the day. c. Return the day. d. Return the next day. e.…arrow_forwardA. Writing an Interface In this problem you will first write an interface and then modify classes to implement the interface. Write an interface, GeometricSolid, which has one method, volume. The volume method takes no arguments and returns a double. You are provided with three classes: Cylinder, Sphere, and RightCircularCone Modify the classes so that they implement the GeometricSolid interface. Supply the appropriate method for each class. You can use Google search to find the formula for the volume. Make sure that you use Math.PI in your calculations. Notice in InterfaceRunner that the objects are added to an ArrayList of GeometricSolids. since I couldn't fit all images with two screen shots I left the link here link: https://codecheck.it/files/18040616319p6jy6gzkdzuq08nmlp81251tarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT