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.

Predict the output of following C++ program.#include <iostream>using namespace std;class A{private:int x;public:A(int _x) { x = _x; }int get() { return x; }};class B{static A a;public:static int get(){ return a.get(); }};int main(void){B b;cout << b.get();return 0;}(A) 0(B) Linker Error: Undefined reference B::a(C) Linker Error: Cannot access static a(D) Linker Error: multiple functions with same name get()

Answer» None
2.

Output of following C++ program?#include <iostream>class Test{public:void fun();};static void Test::fun(){std::cout<<"fun() is static\n";}int main(){Test::fun();return 0;}Contributed by Pravasi Meet(A) fun() is static(B) Empty Screen(C) Compiler Error

Answer» None