Free CPA-21-02 Exam Braindumps (page: 7)

Page 7 of 65

What is the output of the program given below?

#include <iostream>

using namespace std;

int main (int argc, const char * argv[])
{
int i=10;
{
int i=0;
cout<<i;
}
{
i=5;
cout << i;
}
cout<<i;
return 0;
}

  1. 1010
  2. 101010
  3. 055
  4. None of these

Answer(s): C



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

#include <iostream>

using namespace std;

int main (int argc, const char * argv[])
{
int x,y;
union t
{
char tab[2];

int i;
};
union t u;

  1. tab[0] = 1;
  2. tab[1] = 2;
  3. i = 0;
    x = u.tab[0];
    y = u.tab[1];
    cout << x << "," << y << "," << u.i;
    return 0;
    }
  4. compilation fails
  5. It prints: 0,0,0
  6. It prints: 1,2,0
  7. None of these

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,z;
A() : x(1), y(2), z(0) { z = x + y; }
A(int a, int b) : x(a), y(b) { z = x + y;}

void Print() { cout << z; }
};

class B : public A {
public:
int y;
B() : A() {}
B(int a, int b) : A(a,b) {}
void Print() { cout << z; }
};

int main () {
A b;

  1. Print();
    return 0;
    }
  2. It prints: 3
  3. It prints: 0
  4. It prints: 1
  5. It prints: 2

Answer(s): A



Which code, inserted at line 10, generates the output "Hello World"?

#include <iostream>
#include <string>
using namespace std;
string fun(string, string);
int main()
{
string s="Hello";
string *ps;
ps = &s;
//insert code here return 0;
}

string fun(string s1, string s2)
{
return s1+s2;

}

  1. cout << fun(" World");
  2. cout << fun(*ps);
  3. cout << fun("Hello");
  4. cout << fun("Hello", " World");

Answer(s): D



Page 7 of 65



Post your Comments and Discuss C++ Institute CPA-21-02 exam with other Community members:

Subash commented on October 21, 2024
I am planning to take this exam. Are these 257 questions enough to clear it? Also, does each section have a passing percentage, or is it based on the overall ?
INDIA
upvote