Free CPA Exam Braindumps
C++ Certified Associate Programmer Questions 96–100 (page: 21)

Updated On: 9-Feb-2026

What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

int main () {
string s1 = "Hello", s2 = "World";
s2 = s1 + s2;
cout << s2;
return 0;
}

  1. It prints: Hello
  2. It prints: HelloWorld
  3. It prints: WorldHello
  4. It prints: WorldHelloWorld

Answer(s): B



What happens when you attempt to compile and run the following code?

#include <iostream>

using namespace std;

int main()
{
int *t;

t = new int[2];
for (int i=0; i<2; i++) {
t[i]=0;
}

cout << t[1];
}

  1. It prints: 0
  2. It prints: 1
  3. It prints: 2
  4. It prints: 3

Answer(s): A



What happens when you attempt to compile and run the following code?

#include <iostream>

using namespace std;

int main()
{
int x=2, *y, z=3;
y = &z;
cout<<x**y*x***y;
return 0;
}

  1. It prints: 36
  2. It prints: 14
  3. It prints: 16
  4. Compilation error

Answer(s): D



What happens when you attempt to compile and run the following code?

#include <iostream>

using namespace std;

#define DEF_A 0

int main(int argc, char *argv[]) {
cout << DEF_A;
return 0;
}

  1. It prints: 1
  2. It prints: 0
  3. It prints: ?1
  4. Compilation error

Answer(s): B



What happens when you attempt to compile and run the following code?

#include <iostream>
#include <exception>
using namespace std;

class myClass : public exception
{
virtual const char* what() const throw()
{
return "My exception.";
}
} obj;


int main () {
try
{
throw obj;
}
catch (exception& e)
{
cout << e.what() << endl;
}
return 0;
}

  1. It prints: My exception.
  2. It prints: 0
  3. It prints: 1
  4. Compilation error

Answer(s): A



Viewing page 21 of 45
Viewing questions 101 - 105 out of 220 questions


Post your Comments and Discuss C++ Institute CPA exam prep with other Community members:

AI Tutor AI Tutor 👋 I’m here to help!