CPA-21-02 Practice Online

Quickly grab our CPA-21-02 product now and kickstart your exam preparation today!

Name: CPA C++ Certified Associate Programmer
Exam Code: CPA-21-02
Certification: C++ Certified Professional Programmer
Vendor: C++ Institute
Total Questions: 257
Last Updated: May 08, 2024
Page:    1 / 52      
Total 257 Questions | Updated On: May 08, 2024
Question 1

What happens when you attempt to compile and run the following code?
#include <iostream>
using namespace std;
int main()
{
int i = 4;
while(i >= 0) {
cout<<i;
i??;
}
return 0;
}


Answer: A

Question 2

What happens when you attempt to compile and run the following code? #include using namespace std; int main() { int i, j; for(i = 0; i < 2; i++) { for(j = i; j < i + 1; j++) if(j == i) continue; else break; } cout << j; return 0; }


Answer: C

Question 3

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(2), y(2), z(1) { 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;
b.Print();
return 0;
}


Answer: A

Question 4

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



Answer: B

Question 5

What happens when you attempt to compile and run the following code? #include using namespace std; class BaseC { public: int *ptr; BaseC() { ptr = new int(10);} BaseC(int i) { ptr = new int(i); } ~BaseC() { delete ptr; } }; void fun(BaseC x); int main() { BaseC *o = new BaseC(5); fun(*o); } void fun(BaseC x) { cout << "Hello:"<<*x.ptr; }


Answer: C

Page:    1 / 52      
Total 257 Questions | Updated On: May 08, 2024