C++ Questions
Description: Questions which can be used for B.E(First Year), BCA, MCA and IT Placement tests | |
Number of Questions: 14 | |
Created by: Mira Shah | |
Tags: c c plus plus Java/Oracle /C/C++ |
What does a compiler do?
How does the do-while loop different from the while loop?
What does the following C++ statement do? extern int a;
If a class declares a constructor taking one or more parameters but does not declare a default constructor, then
Assume all the relevant header files are included.
In the following code, which function will be called? void print(int) {} void print(int&) {} int iobj; int &ri = iobj;
int main() {
print(iobj);
}
A private member can be accessed only by the
Consider the following array definition int ia[] = { 0, 1, 2, 3, 4, 5 };
What is the equivalent of the following statement? ia;
Which of the following STL containers is an appropriate choice in a situation where a random access into a container is required?
Which of the following is NOT true for C++ reference?
What is the output of the following program? Assume sizeof(int) = 4
#include <iostream> using namespace std;
class Base { static int b; }; class Derived : public Base { int d; }; int main() { Derived objD; cout << sizeof(objD) << endl; }
What is the output of the following program?
#include <iostream> using namespace std;
class Base { public: virtual void fun() { cout << “Base Class” << endl; } }; class Derived : public Base { public: void fun() { cout << “Derived Class” << endl; } }; int main() { Derived objD; Base *ptrB = &objD; ptrB->fun(); }
What is the output of the following program?
#include <iostream> using namespace std;
class Base { public: Base() { cout << “Base Class” << endl; } }; class Derived : public Base { public: Derived() { cout << “Derived Class” << endl; } }; int main() { Derived objD; }
What is the output of the following program?
#include <iostream> using namespace std;
class Base { public: void fun() { cout << “Base Class” << endl; } }; class Derived : public Base { public: void fun() { cout << “Derived Class” << endl; } }; int main() { Derived objD; Base *ptrB = &objD; ptrB->fun(); }
What is the output of the following program?
Assume sizeof( int ) = 4
#include <iostream> using namespace std;
class Base { public: virtual void fun() { cout << “Base Class” << endl; } }; class Derived : public Base { public: void fun() { cout << “Derived Class” << endl; } }; int main() { Base objBase; cout << sizeof( objBase ) << endl; }