C++ Institute certification practice

CPA Practice Questions

Try 10 free CPA exam-style questions for C++ Institute CPA certification exam. Check each answer and review the explanation and source references.

Exam code
CPA
Provider
C++ Institute
Free questions
10
Full set
220 questions
Last update check
What happens when you attempt to compile and run the following code? #include #include using namespace std; class A { protected: int y; public: int x,z; A() : x(1), y(2), z(0) { z = x + y; } A(int a, int b) : x(a), y(b) { z = x + y;} void Print() { cout << z; } }; class B : public A { public: int y; B() : A() {} B(int a, int b) : A(a,b) {} void Print() { cout << z; } }; int main () { A b; b.Print(); return 0; }
Answer options
What happens when you attempt to compile and run the following code? #include using namespace std; int fun(int x); int main() { cout < 0) return fun(x-1); else return 100; }
Answer options
What happens when you attempt to compile and run the following code? #include using namespace std; int main(int argc, char *argv[]) { char *s = "ABCDEF"; cout << s+2; return 0; }
Answer options
What happens when you attempt to compile and run the following code? #include using namespace std; class A { public: void Print(){ cout<<"A";} }; class B:public A { public: void Print(){ cout<Print(); B ob2; obj = &ob2; obj?>Print(); }
Answer options
What happens when you attempt to compile and run the following code? #include #include using namespace std; class A { public: A() { cout << "A0 ";} A(string s) { cout << "A1";} }; class B : public A { public: B() { cout << "B0 ";} B(string s) { cout << "B1 ";} }; class C : private B { public: C() { cout << "C0 ";} C(string s) { cout << "C1 ";} }; int main () { B b1; C c1; return 0; }
Answer options
What is the output of the program given below? #include using namespace std; int main (int argc, const char * argv[]) { int i=10; { int i=0; cout<<i; } { int i=5; cout << i; } cout<<i; return 0; }
Answer options
Which code, inserted at line 10, generates the output "Hello World"? #include #include using namespace std; string fun(string, string); int main() { string s="Hello"; string *ps; ps = &s; //insert code here return 0; } string fun(string s1, string s2) { return s1+s2; }
Answer options
What happens when you attempt to compile and run the following code? #include using namespace std; class A { public : void print() { cout << "A "; } }; class B { public : void print() { cout << "B "; } }; int main() { B sc[2]; A *bc = (A*)sc; for (int i=0; iprint(); return 0; }
Answer options
What happens when you attempt to compile and run the following code? #include using namespace std; int main (int argc, const char * argv[]) { int a = 30, b = 1, c = 5, i=10; i = b < a < c; cout << i; return 0; }
Answer options
What is the output of the program? #include using namespace std; int main() { int tab[4]={10,20,30,40}; tab[1]=10; int *p; p=&tab[0]; cout<<*p; return 0; }
Answer options
Question 1 of 10

Source context

How this practice set is maintained

Maintained by the CertMage content team, this page loads questions from the exam dataset connected to its preparation resource. When an answer includes a supporting reference, it is shown with that answer so you can review the underlying vendor documentation.

Certification objectives, interfaces, and vendor services can change. Verify important details against the provider's current exam guide and documentation before your exam.

Scroll to Top