Official Bank 0/220

C++ Certified Associate Programmer (CPA) - CPPL Exam Questions

Last updated on June 20, 2026

97% Exam Compliance
220 Total Questions
1
Question
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:
virtual void Print(){ cout<< "B";}
};
{
int main()
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}
Options
A It prints: BB
B It prints: AA
C It prints: AB
D It prints: BA
Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

2
Question
Given: #include #include
using namespace std;
int main () {
try
{
int * myarray= new int[1000];
}
{
catch (bad_alloc&)
cout << "Error allocating memory";
}
{
catch (exception& e)
cout << "Standard exception";
}
{
catch (...)
cout << "Unknown exception";
}
return 0;
}

What will happen if we use the operator “new” and the memory cannot be allocated?
Options
A Compilation error
B It prints: Standard exception
C It prints: Error allocating memory
D It prints: Unknown exception
Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

3
Question
What happens when you attempt to compile and run the following code? #include #include
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
};
class B : private A {
string name;
public:
void set() {
x = 1;
}
void Print() {
cout << x;
}
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
Options
A Compilation error
B It prints: 1
C It prints: 123
D It prints: ?123
Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

4
Question
If there is one, point out an error in the program
#include
using namespace std;
int main()
{
int c = 'a';
switch(i)
{
case '2':
cout<<"OK";
case '1':
cout<<"Error";
default:
break;
}
return 0;
}
Options
A Illegal use of 'break'
B Use of undeclared identifier 'i'
C No Error
D Illegal use of 'continue'
Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

5
Question
What is the output of the program if character “1” is supplied as input? #include
using namespace std;
int main () {
int c;
cin >> c;
try
{
switch (c)
{
case 1:
throw 20;
case 2:
throw 5.2f;
case 3:
throw 'a';
}
}
catch (int e)
{ cout << "int exception. Exception Nr. " << e; }
catch (float e)
{ cout << "float exception. Exception Nr. " << e; }
catch (...)
{ cout << "An exception occurred."; }
return 0;
}
Options
A Compilation Error
B It prints: int exception. Exception Nr. 20
C It prints: float exception. Exception Nr. 5.2
D It prints: An exception occurred
Discussion (0 comments)

to join the discussion

Community Discussion

No discussions yet. Be the first to ask!

Finish Practice?

Are you sure you want to finish? This will end your practice session.