Free CPA Exam Braindumps
C++ Certified Associate Programmer Questions 66–70 (page: 15)

Updated On: 9-Feb-2026

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

#include <iostream>
using namespace std;

int main(){
int i, j;
for(i = 0, j = 1; j < 2, i < 4; i++, j++);
cout << i << " " << j;
return 0;
}

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

Answer(s): A



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

#include <iostream>
#include <cstdarg>

using namespace std;

int mult(int f, int s, int t);

int main()
{
cout << mult(1,2,3);
return 0;
}


int mult(int f, int s, int t)
{
int mult_res;
mult_res = f*s*t;
return mult_res;
}

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

Answer(s): B



Which code, inserted at line 5, generates the output "ABC"?

#include <iostream>
using namespace std;
class A {
public:
//insert code here
};
class B:public A {
public:
void Print(){ cout<< "B"; }
};
class C:public B {
public:
void Print(){ cout<< "C"; }
};
int main()
{
A ob1;
B ob2;
C ob3;
A *obj;
obj = &ob1;
obj?>Print();
obj = &ob2;
obj?>Print();
obj = &ob3;
obj?>Print();
}

  1. void Print(){ cout<<"A";}
  2. virtual void Print(){ cout<<"A";}
  3. virtual void Print(string s){ cout<<s;}
  4. None of these

Answer(s): B



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

#include <iostream>

using namespace std;

class BaseClass
{
public:
int *ptr;
BaseClass(int i) { ptr = new int(i); }
~BaseClass() { delete ptr; delete ptr;}
void Print() { cout << *ptr; }
};
void fun(BaseClass x);


int main()
{
BaseClass o(10);
fun(o);
o.Print();
}


void fun(BaseClass x) {
cout << "Hello:";
}

  1. It prints: Hello:1
  2. It prints: Hello:
  3. It prints: 10
  4. Runtime error.

Answer(s): D



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

#include <iostream>

using namespace std;

int getValue();

int main()
{
const int x = getValue();
cout<<x;
return 0;
}
int getValue()
{
return 5;
}

  1. It will print 0
  2. The code will not compile.
  3. It will print 5
  4. It will print garbage value

Answer(s): C



Viewing page 15 of 45
Viewing questions 71 - 75 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!