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 happens when you attempt to compile and run the following code?
#include < iostream >
#include < string >
using namespace std;
const int size = 3;
class A {
public:
string name;
A() { name = " Bob " ;}
A(string s) { name = s;}
A(A & a) { name = a.name;}
};
class B : public A {
public:
int *tab;
B() { tab = new int[size]; for (int i=0; i < size; i++) tab[i]=1;}
B(string s) : A(s) { tab = new int[size]; for (int i=0; i < size; i++) tab[i]=1;}
~B() { delete tab; }
void Print() {
for (int i=0; i < size; i++) cout < < tab[i];
cout < < name;
}
};
int main () {
B b1( " Alan " );
B b2;
b1.tab[0]=0;
b1.Print(); b2.Print();
return 0;
}
What happens when you attempt to compile and run the following code?
#include < iostream >
#include < string >
using namespace std;
class A {
int x;
protected:
int y;
public:
int z;
A() { x=1; y=2; z=3; }
};
class B : public A {
string z;
public:
void set() { y = 4; z = " John " ; }
void Print() { cout < < y < < A::z; }
};
int main () {
B b;
b.set();
b.Print();
return 0;
}
What happens when you attempt to compile and run the following code?
#include < iostream >
#include < string >
using namespace std;
int main()
{
string s1[]= { " H " , " t " };
string s;
for (int i=0; i < 2; i++) {
s = s1[i];
s.insert(1, " o " );
cout < < s;
}
return( 0 );
}
What is the output of the program?
#include < iostream >
#include < string >
using namespace std;
int main()
{
string s1[]= { " H " , " t " };
string s;
for (int i=0; i < 2; i++) {
s = s1[i];
if (i==0)
s.insert(1, " ow " );
else
s.push_back( ' o ' );
cout < < s;
}
return( 0 );
}
Which code, inserted at line 12, generates the output " 5b " ?
#include < iostream >
using namespace std;
namespace myNamespace1
{
int var = 5;
}
namespace myNamespace2
{
char var = ' b ' ;
}
int main () {
//insert code here
return 0;
}
How many times will " HELLO " be printed?
#include < iostream >
using namespace std;
int main()
{
for(int i=?1; i < =10; i++)
{
if(i < 5)
continue;
else
break;
cout < < " HELLO " ;
}
return 0;
}
What happens when you attempt to compile and run the following code?
#include < iostream >
using namespace std;
class First
{
public:
First() { cout < < " Constructor " ;}
~First() { cout < < " Destructor " ;}
void Print(){ cout < < " from First " ;}
};
int main()
{
First FirstObject;
FirstObject.Print();
}
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 >
using namespace std;
int mul (int a, int b=2)
{
int r;
r=a*b;
return (r);
}
int main ()
{
cout < < mul(1) < < mul(2,4);
return 0;
}
Which of the following operations is INCORRECT?
