In the following code, which definition of writeOutput is invoked? (The classes are defined in the previous case study.)
Undergraduate ug = new Undergraduate (“Sam”, 999, 1);
Personp = (Person) ug;
p.writeOutput();
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
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Introduction To Programming Using Visual Basic (11th Edition)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
- Why is a destructor function required in classes? Illustrate with the help of an example ?arrow_forwardGiven these three arguments, please explain why it is better to have accessors for private types rather than making them public.arrow_forwardWrite c# equivalent statements for the following: There is a book library. Define classes respectively for a library. The library must contain a name and a list of books (use array). The books only contain author name as information. In the class, which describes the library, create methods to add a book to the library, to search for a book by a predefined author, and to delete a book from the library. Write a test class, which creates an object of type library, adds several books to it. Implement a test functionality, which finds all books authored by Stephen King and deletes them. Finally, display information for each of the remaining books.arrow_forward
- Using the scenario of Object oriented programming Q1 Write a program that defines a class with a data member to holds a “serial number” for each object created from the class. That is, the first object created will be numbered 1, the second 2, and so on. To do this, you’ll need another data member that records a count of how many objects have been created so far. (This member should apply to the class as a whole; not to individual objects. What keyword specifies this?) Then, as each object is created, its constructor can examine this count member variable to determine the appropriate serial number for the new object. Add a member function that permits an object to report its own serial number. Then write a main() program that creates three objects and queries each about its serial number. They should respond I am object number 2, and so on.arrow_forwardplease solve in python languange and use proper comments for better understanding . Thank you.arrow_forwardHelp of what these errors mean. In C# • Create a Class, named Student, to hold properties of Student Last Name, Student First Name, Student ID (9 digits), Course Prefix and Number, and the tests (Test 1, Test 2, Test 3, Test 4). Create appropriate setter and getter accessors, and constructors. Use access modifiers. Example: First Name : Pat Last Name : Smythe Student ID : ABC111333 Course Prefix : CIST Course Name : 2431 Test 1 : 100 Test 2 : 90 Test 3 : 80 Test 4 : 88 • Prompt the user for the Student Last and First Name, Student ID, Course Prefix and Number and the tests. • Include at least one exception handling function. • Use an array to store the 4 test grades. • Use a looping structure to populate the array. • Calculate the numeric average based upon the 4 equally-weighted numeric grades. • Display all the data for each of student using a looping structure. • Display the numeric average for each student. • Create a function that will convert the numeric average to a…arrow_forward
- use java (ArrayList, inheritance, polymorphism, File I/O and basic Java) Student class: First, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A first name (given name) A last name (family name/surname) Student number (ID) – an integer number (of type long) The Student class will have at least the following constructors and methods: (i) two constructors - one without any parameters (the default constructor), and one with parameters to give initial values to all the instance variables of Student. (ii) only necessary set and get methods for a valid class design. (iii) a reportGrade method, which you have nothing to report here, you can just print to the screen a message “There is no grade here.”. This method will be overridden in the respective child classes. (iv) an equals method which compares two student objects and returns true if they…arrow_forwardQUESTION 4 (use c++ to answer the following question) Note: You need to add required constructors/destructors, member functions or data members/variables in your program to complete its execution. Suppose we are designing a record-keeping program that has records for salariedemployees and hourly employees. There is a natural hierarchy for grouping these classes.These are all classes of people who share the property of being employees.Employees who are paid an hourly wage are one subset of employees. Anothersubset consists of employees who are paid a fixed wage each month or week. Although the program may not need any type corresponding to the set of all employees, thinking in terms of the more general concept of employees can be useful. For example, all employees have names, Social Security numbers (ssn) and net pay, and the member functions for setting and changing the name, ssn and netpay would be same for both hourly and salaried employees. Implement the above mentioned…arrow_forwardTwo base classes have functions with the same name, while a class derived from both base classes has no function with this name. How do objects of the derived class access the correct base class function? Write your own program to explain the answer.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning