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
Java Programming (MindTap Course List)
- Create 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_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
- 1. 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_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
- in C++arrow_forwardCreate a class: Question 1 with data members: 1D integer array of maximum size: 100, n (int). Create a dynamic constructor which takes input of n and n no. of array elements. Apart from taking input this class also displays the maximum and minimum elements from the given array elements.arrow_forwardQ# A program that has no graphical user interface and only takes input through the command line only has a model and a controller. It does not have a view. The answer: is FALSE. Please explain with example. Q# What is NOT an effect of the SOLID principles? The answer: A high-level class depends on specific low-level classes and not interfaces. Please explain why. Q# Assume you are considering writing a method and are deciding what should happen when given input that is outside of perfect input. Which of the following is not a way to handle this? Answer: Use better JUnit testing. Subject: Java Programmingarrow_forward
- Create 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_forwardCreate a Right Triangle class that has two sides. Name your class rightTraingle. Code getter and setters for the base and the height. (Remember class variables are private.) The class should include a two-argument constructor that allows the program to set the base and height. The constructor should verify that all the dimensions are greater than 0. before assigning the values to the private data members. If a side is not greater than zero, set the value to -1. The class also should include two value-returning methods. One value-returning method should calculate the area of a triangle, and the other should calculate the perimeter of a triangle. If either side is -1, these functions return a -1. The formula for calculating the area of a triangle is 1/2 * b*h, where b is the base and h is the height. The formula for calculating the perimeter of a triangle is b+h+sqrt (b*b+h*h). Be sure to include a default constructor that initializes the variables of the base, height to -1. To test…arrow_forward2. Write a class encapsulating a board game, which inherits from Game. A board game has the following additional attributes: the minimum number of players, the maximum number of players, and whether there is a time limit to finish the game. Code the constructor and the toString() method of the new class. You also need to include a client class to test your code.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT