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

Page 25 of 65

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

#include <iostream>

using namespace std;

int main()
{
int *t;

t = new int[2];
for (int i=0; i<2; i++) {
t[i]=0;
}

cout << t[1];
}

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

Answer(s): A



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

#include <iostream>

using namespace std;

int main()
{
int x=2, *y, z=3;
y = &z;
cout<<x**y*x***y;
return 0;
}

  1. It prints: 36
  2. It prints: 14
  3. It prints: 16
  4. Compilation error

Answer(s): D



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

#include <iostream>

using namespace std;

#define DEF_A 0

int main(int argc, char *argv[]) {
cout << DEF_A;
return 0;
}

  1. It prints: 1
  2. It prints: 0
  3. It prints: ?1
  4. Compilation error

Answer(s): B



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

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

class myClass : public exception
{
virtual const char* what() const throw()
{
return "My exception.";
}
} obj;

int main () {
try
{
throw obj;
}
catch (exception& e)
{
cout << e.what() << endl;
}
return 0;
}

  1. It prints: My exception.
  2. It prints: 0
  3. It prints: 1
  4. Compilation error

Answer(s): A



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