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

Page 34 of 65

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

#include <iostream>
#include <string>

using namespace std;

string fun(string, string);

int main()
{
string s="Hello";
cout << fun(s, " World");
return 0;
}

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

  1. It will print: Hello World
  2. It will print: Hello
  3. It will print: World
  4. It will print: HW

Answer(s): A



What is not inherited from the base class?

  1. constructor
  2. destructor
  3. operator=()
  4. operator+()

Answer(s): A,B,C



How many times will the program print "HELLO" ?

#include <iostream>

using namespace std;

int main()
{
cout<<"HELLO";
main();
return 0;
}

  1. 65536
  2. 32769
  3. 1
  4. Till stack overflows

Answer(s): D



What is the output of the program?

#include <iostream>
#include <string>

using namespace std;

union t
{
char c;

int i;
};

class First
{
union t u;
public:
First() {

  1. c = 'A';
    }
    void Print(){

    cout << u.c;
    }
    };
    int main()
    {
    First *t = new First();
    t?>Print();
    }
  2. Garbage value
  3. It prints: A
  4. It prints: A 65
  5. Compilation error

Answer(s): B



Page 34 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