Free CPA Exam Braindumps
C++ Certified Associate Programmer Questions 56–60 (page: 13)

Updated On: 9-Feb-2026

Which of the following can be checked in a switch?case statement?

  1. char
  2. int
  3. enum
  4. double

Answer(s): A,B,C



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;
};


class B : public A {
string name;
public:
void set() {
y = 2;
z = 3;
}
void Print() { cout << y << z; }
};
int main () {
B b;
b.set();
b.Print();
return 0;
}

  1. It prints: 123
  2. It prints: 000
  3. It prints: 23
  4. It prints: 12

Answer(s): C



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

#include <iostream>

using namespace std;

class A
{
public:
void Print(){ cout<<"A";}
};
class B:public A
{
public:
void Print(){ cout<< "B";}
};
int main()
{
A *obj;
A ob1;
obj = &ob1;
obj?>Print();
B ob2;
obj = &ob2;
obj?>Print();
}

  1. It prints: AB
  2. It prints: AA
  3. It prints: BA
  4. It prints: BB

Answer(s): B



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

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


class A {
protected:
int y;
public:
int x;
int z;
A() { x=2; y=2; z=3; }
A(int a, int b) : x(a), y(b) { z = x ? y;}
void Print() {
cout << z;
}
};


int main () {
A a(2,5);
a.Print();
return 0;
}

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

Answer(s): A



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

#include <iostream>

using namespace std;

void fun(int*);

int main()
{
int i=2;
fun(&i);
cout<<i;
return 0;
}


void fun(int *i)
{
*i = *i**i;
}

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

Answer(s): B



Viewing page 13 of 45
Viewing questions 61 - 65 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!