Curioustab
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Aptitude
General Knowledge
Verbal Reasoning
Computer Science
Interview
Take Free Test
Functions Questions
C++ (method hiding vs base call) — what happens when a derived Display() calls Display() without qualification? #include
class Base { int x, y, z; public: Base() { x = y = z = 0; } Base(int xx, int yy = 'A', int zz = 'B') { x = xx; y = x + yy; z = x + y; } void Display(void) { cout << x << " " << y << " " << z << endl; } }; class Derived : public Base { int x, y; public: Derived(int xx = 65, int yy = 66) : Base(xx, yy) { y = xx; x = yy; } void Display(void) { cout << x << " " << y << " "; Display(); } }; int main() { Derived objD; objD.Display(); return 0; } Choose the correct statement.
In legacy C++ (iostream.h), what happens when a private member function is called from main versus a public one? Carefully read the code and predict the program's behavior. #include
class CuriousTabSample { private: int AdditionOne(int x, int y = 1) { return x * y; } public: int AdditionTwo(int x, int y = 1) { return x / y; } }; int main() { CuriousTabSample objCuriousTab; cout << objCuriousTab.AdditionOne(4, 8) << " "; cout << objCuriousTab.AdditionTwo(8, 8); return 0; }
1
2
3
4