C++ Certified Associate Programmer (CPA) - CPPL Exam Questions
Last updated on June 20, 2026
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();
}
to join the discussion
No discussions yet. Be the first to ask!
Delete Comment
Are you sure? This action cannot be undone.
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?
to join the discussion
No discussions yet. Be the first to ask!
Delete Comment
Are you sure? This action cannot be undone.
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;
}
to join the discussion
No discussions yet. Be the first to ask!
Delete Comment
Are you sure? This action cannot be undone.
#include
using namespace std;
int main()
{
int c = 'a';
switch(i)
{
case '2':
cout<<"OK";
case '1':
cout<<"Error";
default:
break;
}
return 0;
}
to join the discussion
No discussions yet. Be the first to ask!
Delete Comment
Are you sure? This action cannot be undone.
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;
}
to join the discussion
No discussions yet. Be the first to ask!
Delete Comment
Are you sure? This action cannot be undone.
Finish Practice?
Are you sure you want to finish? This will end your practice session.