Last Update 19 hours ago Total Questions : 257
The CPA - C++ Certified Associate Programmer content is now fully updated, with all current exam questions added 19 hours ago. Deciding to include CPA-21-02 practice exam questions in your study plan goes far beyond basic test preparation.
You'll find that our CPA-21-02 exam questions frequently feature detailed scenarios and practical problem-solving exercises that directly mirror industry challenges. Engaging with these CPA-21-02 sample sets allows you to effectively manage your time and pace yourself, giving you the ability to finish any CPA - C++ Certified Associate Programmer practice test comfortably within the allotted time.
What is the output of the program if character 4 is supplied as input?
#include < iostream >
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 ' ;
default:
cout < < " No exception " ;
}
}
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;
}
Which of the structures is incorrect?
1:
struct s1{
int x;
long int li;
};
2:
struct s2{
float f;
struct s2 *s;
};
3:
struct s3{
float f;
struct s3 s;
};
What happens when you attempt to compile and run the following code?
#include < iostream >
#include < string >
using namespace std;
class A {
public:
A() { cout < < " A no parameters " ;}
A(string s) { cout < < " A string parameter " ;}
A(A & a) { cout < < " A object A parameter " ;}
};
class B : public A {
public:
B() { cout < < " B no parameters " ;}
B(string s) { cout < < " B string parameter " ;}
};
int main () {
A a2( " Test " );
B b1( " Alan " );
B b2(b1);
return 0;
}
What happens when you attempt to compile and run the following code?
#include < iostream >
using namespace std;
class A {
public:
virtual void Print()=0;
};
class B:public A {
public:
virtual void Print() { cout < < " B " ; }
};
class C:public A {
public:
virtual void Print() { cout < < " C " ; }
};
int main()
{
B ob2;
C ob3;
A *obj;
obj = & ob2;
obj? > Print();
obj = & ob3;
obj? > Print();
}
What happens when you attempt to compile and run the following code?
#include < iostream >
#include < string >
using namespace std;
class A {
public:
int x;
A() { x=0;}
A(int x) { this? > x=x;}
};
class B : private A {
public:
using A::x;
B() { x=1;}
B(int x) {this? > x = x;}
};
int main () {
B c1;
B c2(?5);
cout < < c1.x;
cout < < c2.x;
return 0;
}
What happens when you attempt to compile and run the following code?
#include < iostream >
using namespace std;
int main(){
int i = 1;
for(i=10; i > -1; i/=2) {
if(!i)
break;
}
cout < < i;
return 0;
}
What will the variable " y " be in class B?
class A {
int x;
protected:
int y;
public:
int age;
};
class B : protected A {
string name;
public:
void Print() {
cout < < name < < age;
}
};
What will be the output of the program?
#include < iostream >
using namespace std;
int main()
{
const int y = 5;
const x = ?10;
cout < < x < < " " < < y;
return 0;
}
What happens when you attempt to compile and run the following code?

What happens when you attempt to compile and run the following code?
#include < iostream >
#include < string >
using namespace std;
class Base
{
string s;
public:
Base() { s= " Sample text " ;}
Base(string s) { this? > s=s; }
void Print() { cout < < s; }
};
int main()
{
Base *o = new Base();
o? > Print();
}
