Topics for the in-class exam will include but are not limited to: a. Passing arguments b. Command line arguments c. Control structures d. Pointers and references e. Arrays f. Object instantiation g. Exception handling h. Inheritance i. Polymorphism j. Files and streams k. Recursion Six example questions (3 C++ and 3 Java questions) are listed below: I. C++ example question #1: Recursion Given the following code, determine which of the options A .. E best describes what the code does, assuming firstNodePtr contains the address of the first node in a linked list of objects of type Employee: class Employee; int functionX(Employee *); class Employee { public: Employee(); int getSalary(); Employee *getNextEmployee(); void setSalary(int); void setNextEmployee(Employee *); private: int salary; Employee *nextEmployee; }; int functionX(Employee *firstNodePtr) { Employee *currentPtr = firstNodePtr; int numEmployees = 0; if(currentPtr != 0) { while(currentPtr != 0) { if(currentPtr->getSalary() < 1000.00) { numEmployees++; } } } return numEmployees; } A. functionX will return the number of nodes in the linked list B. functionX will return the number of nodes in the linked list for which the salary is 1000.00 or less C. functionX will not do anything because firstNodePtr is coming in by value D. functionX will result in an infinite loop E. functionX will return the value 1 (one) ANSWER: D II. Java example question #1: Recursion Given the following code, determine which of the options A .. E best describes what the code does, assuming beginRef contains the address of the first node in a linked list of references to objects of type Employee: public class X { ... int functionX(Employee beginRef) { Employee currentRef = beginRef; int numEmployees = 0; if(currentRef != null) { while(currentRef != null) { if(currentRef.getSalary() < 1000.00) { numEmployees++; } } } return numEmployees; } } class Employee { private int salary; private Employee nextEmployee; Employee() {...} int getSalary() {...} void setSalary(int T) {...} }; A. functionX will return the number of nodes in the linked list B. functionX will return the number of nodes in the linked list for which the salary is 1000.00 or less C. functionX will not do anything because beginRef is coming in by value D. functionX will result in an infinite loop E. functionX will return the value 1 (one) ANSWER: D III. C++ example question #3: Object Instantiation Assuming that the Employee class contains definitions for two constructors (a no-argument constructor, and a copy constructor), determine which of the declarations A .. E provides the best code for instantiating one object of class Employee: int main(void) { } A. Employee *E; B. Employee &E(); C. Employee E(); D. Employee *E[3]; E. Employee &Eref; ANSWER: C IV. Java example question #4: Object Instantiation Assuming that the Employee class and the Test class are in the same package and that class Employee contains definitions for two constructors (a no- argument constructor and a copy constructor), determine which of the declarations A .. E provides the best code for instantiating one object of class Employee: public class Test { public static void main(String args[]) { } } A. Employee E(); B. Employee &ERef = new Employee(); C. Employee E = new Employee(); D. Employee E; E. Employee *Eptr = new Employee(); ANSWER: C V. C++ example question #5: Object dereferencing Assuming that the Employee class has a public member function defined as double setSalary(double D) { salary = ((D > 0.00) && (D < 1000.00)) ? D : 542.39; } and a private data member declared as double salary; and that an object E of class Employee is in scope in the main functiiion below, determine which of the options A .. E provides the best code for modifying the value of the salary data member in E: int main(void) { ... assume an object E of class Employee is in scope } A. E.setSalary(840.46); B. E.salary = 840.46; C. E->salary = 840.46; D. E.setSalary("840.46"); E. E.salary = "840.46"; ANSWER: A VI. Java example question #6: Object dereferencing Assuming that the Employee class and the Test class are in the same package that that the Employee class has a public method defined as public double setSalary(double D) { salary = ((D > 0.00) && (D < 1000.00)) ? D : 542.39; } and an instance variable declared as private double salary; and that an object of class Employee is in scope in the following method in the Test class (and is referred to by the Employee reference ERef), determine which of the options A .. E provides the best code for modifying the value of the salary instance variable: public class Test { private Employee ERef; public static void main(String args[]) { ERef = new Employee(); } A. ERef.setSalary(840.46); B. ERef.salary = 840.46; C. ERef->salary = 840.46; D. ERef.setSalary("840.46"); E. ERef.salary = "840.46"; ANSWER: A