Free CPA Exam Braindumps
C++ Certified Associate Programmer Questions 71–75 (page: 16)

Updated On: 9-Feb-2026

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

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


class A {
public:
A() { cout << "A0 ";}
A(string s) { cout << "A1";}
};


class B : public A {
public:
B() { cout << "B0 ";}
B(string s) { cout << "B1 ";}
};


class C : private B {
public:
C() { cout << "C0 ";}
C(string s) { cout << "C1 ";}
};


int main () {
B b1;
C c1;
return 0;
}

  1. It prints: A0 B0 A0 B1 A0 C0 A0 C1
  2. It prints: B0 B1 C0 C1
  3. It prints: A0 B0 A0 B0 C0
  4. It prints: B0 B1

Answer(s): C



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

struct Person {
int age;
};


class First
{
Person *person;
public:
First() {person = new Person;
person?>age = 20;
}
void Print(){
cout << person?>age;
}
};


int main()
{
First t[2];
for (int i=0; i<2; i++)
t[i].Print();
}

  1. It prints: 10
  2. It prints: 2020
  3. It prints: 22
  4. It prints: 00

Answer(s): B



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

#include <cstdlib>
#include <iostream>

using namespace std;

inline float sum(float a,float b)
{
return a+b;
}


int main()
{
float a,b;
a = 1.5; b = 3.4;
cout<<sum(a,b);
return 0;
}

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

Answer(s): B



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

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

  1. It prints: HelloWorld
  2. It prints: Hello
  3. It prints: World
  4. It prints: HelWorld

Answer(s): A



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

#include <iostream>

using namespace std;


#define DEF_A 0
#define DEF_B DEF_A+1
#define DEF_C DEF_B+1


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

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

Answer(s): A



Viewing page 16 of 45
Viewing questions 76 - 80 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!