Free CPA-21-02 Exam Braindumps

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

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

class A {
public:
A() { cout << "A no parameters";}
A(string s) { cout << "A string parameter";}
A(A &a) { cout << "A object A parameter";}
};

class B : public A {
public:
B() { cout << "B no parameters";}
B(string s) { cout << "B string parameter";}
};

int main () {
A a2("Test");
B b1("Alan");
B b2(b1);
return 0;

}

  1. It prints: A no parametersA no parametersB string parameter
  2. It prints: A string parameterA no parametersB string parameterA object A parameter
  3. It prints: A no parametersB string parameter
  4. It prints: A no parametersA no parameters

Answer(s): B



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

#include <iostream>
#include <string>

using namespace std;

class A {
public:
string s;
A(string s) { this?>s = s; }
};

class B {
public:
string s;
B (A a) { this?>s = a.s; }
void print() { cout<<s; }
};

int main()
{
A a("Hello world");
B b=a;

  1. print();
    }
  2. It prints: Hello world
  3. It prints: Hello
  4. Compilation error
  5. None of these

Answer(s): A



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

#include <iostream>

using namespace std;

int op(int x, int y);

int main()
{
float *pf;
float f=0.9;
pf=&f;
cout << op(1, *pf);
return 0;

}

int op(int x, int y)
{
return x*y;
}

  1. It prints: 0
  2. It prints: 0.5
  3. It prints: 1
  4. It prints: ?1

Answer(s): A



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

#include <iostream>
#include <string>

using namespace std;

class First
{
string *s;
public:
First() { s = new string("Text");}
~First() { delete s;}
void Print(){ cout<<*s;}
};
int main()
{
First FirstObject;

FirstObject.Print();
FirstObject.~First();
}

  1. It prints: Text
  2. Compilation error
  3. Runtime error.
  4. None of these

Answer(s): C






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