Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following overloaded functions are NOT allowed in C++?1) Function declarations that differ only in the return type int fun(int x, int y); void fun(int x, int y); 2) Functions that differ only by static keyword in return type int fun(int x, int y); static int fun(int x, int y); 3)Parameter declarations that differ only in a pointer * versus an array []int fun(int *ptr, int n);int fun(int ptr[], int n); 4) Two parameter declarations that differ only in their default argumentsint fun( int x, int y); int fun( int x, int y = 10); (A) All of the above(B) All except 2)(C) All except 1)(D) All except 2 and 4

Answer»
2.

Predict the output of following C++ program.include<iostream>using namespace std;class Test{protected:int x;public:Test (int i):x(i) { }void fun() const { cout << "fun() const " << endl; }void fun() { cout << "fun() " << endl; }};int main(){Test t1 (10);const Test t2 (20);t1.fun();t2.fun();return 0;}(A) Compiler Error(B) fun()fun() const(C) fun() constfun() const(D) fun()fun()

Answer»
3.

Output?#include<iostream>using namespace std;int fun(int x = 0, int y = 0, int z){ return (x + y + z); }int main(){cout << fun(10);return 0;}(A) 10(B) 0(C) 20(D) Compiler Error

Answer» None
4.

Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++.(A) Inheritance(B) Polymorphism(C) Encapsulation(D) None of the above

Answer»