Free C++ Institute CPA 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;
b.print();
}

  1. It prints: Hello world
  2. It prints: Hello
  3. Compilation error
  4. 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



Viewing page 10 of 56
Viewing questions 37 - 40 out of 220 questions



Post your Comments and Discuss C++ Institute CPA exam prep with other Community members:

CPA Exam Discussions & Posts