Question
Exercise #10 Given 3 options for Function Overloading: // Option 1 // void testFunc(int num) { cout < < Int num * num =
Exercise #10 Given 3 options for Function Overloading: // Option 1 // void testFunc(int num) { cout << "Int num * num = " << num * num << endl; } void testFunc(double num) { cout << "Double num*num = " << num * num << endl; } // Option 2 // int testFunc(int num) { cout << "Int num * num = " << num * num << endl; return num * num; } void testFunc(int num) { cout << "Double num*num = " << num * num << endl; } // Option 3 // double testFunc(int num) { cout << "Int num * num = " << num * num << endl; return num * num; } int testFunc(int num) { cout << "Double num*num = " << num * num << endl; return num * num; } Choose the right answer : a. Only Option 1 is wrong . b. Only Option 2 is wrong . c. Both Options 2 and 3 are wrong. d. None of the options is wrong.
Exercise #11 Given the following program: class X { public: X(int i = 0) : n(i) { } void f() const { cout << n; } // method 1 void f() { cout << n * 2; } // method 2 int n; }; int main() { X x1(2); const X x2(3); x1.f(); x2.f(); } What f methods will call objects x1 and x2? a. x1 will call method 1 and x2 will call method 2. b. x1 will call method 2 and x2 will call method 1. c. Compilation Error. d. Both will call the same method with same functionality. Exercise #12 Given the following program: class X { public: X(int i = 0) : n(i) { } void f() const { cout << n; } void f() { cout << n * 2; } int n; }; int main() { X x1(2); const X x2(3); x1.f(); x2.f(); } Given: X(int i = 0) : n(i)? What is n(i)? a. Its a virtual function. b. Used to initialize data member n with value of i". c. Operator. d. Function called n. Exercise #13 Given the following program: class X { public: X(int i = 0) : n(i) { } void f() const { cout << n; } void f() { cout << n * 2; } int n; }; int main() { X x1(2); const X x2(3); x1.f(); x2.f(); } What is X(int i = 0)? a. Copy Constructor receiving an object of X type. b. Default Constructor (supporting receiving 1 integer). c. Destructor. d. A Virtual Method Function. Exercise #14 Given the following program: class X { public: X(int i = 0) : n(i) { } void f() const { cout << n; } void f() { cout << n * 2; } int n; }; int main() { X x1(2); const X x2(3); x1.f(); x2.f(); } What is the expected result from the execution of this program? a. 42 b. 34 c. 43 d. 26
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started