Free CPA – C++ Certified Associate Programmer Exam CPA-21-02 Exam Practice Test

UNLOCK FULL
CPA-21-02 Exam Features
In Just $59 You can Access
  • All Official Question Types
  • Interactive Web-Based Practice Test Software
  • No Installation or 3rd Party Software Required
  • Customize your practice sessions (Free Demo)
  • 24/7 Customer Support
Page: 1 / 52
Total Questions: 257
  • Which of the following operations is INCORRECT?

    Answer: C Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>#include <string>using namespace std;const int size = 3; class A {public:string name;A() { name = "Bob";} A(string s) { name = s;}A(A &a) { name = a.name;}};class B : public A { public:int *tab;B() { tab = new int[size]; for (int i=0; i<size; i++) tab[i]=1;}B(string s) : A(s) { tab = new int[size]; for (int i=0; i<size; i++) tab[i]=1;}~B() { delete tab; } void Print() {for (int i=0; i<size; i++) cout << tab[i]; cout << name;}};int main () {B b1("Alan"); B b2;b1.tab[0]=0; b1.Print(); b2.Print(); return 0;}

    Answer: C Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;int main(){int i = 5; do {i??;cout<<i;}while(i >= 0);return 0;}

    Answer: A Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;class complex{ double re; double im; public:complex() : re(0),im(0) {} complex(double x) { re=x,im=x;}; complex(double x,double y) { re=x,im=y;} void print() { cout << re << " " << im;}};int main(){ complex c1; double i=2; c1 = i; c1.print(); return 0;}

    Answer: D Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;int main(){int *a= new int;*a=100;cout << *a; delete a;}

    Answer: B Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;void set(struct person*); struct person{char name[25]; int age;};int main(){struct person e = {"Steve", 30}; set(&e);cout<< e.name << " " << e.age; return 0;}void set(struct person *p){p?>age = p?>age + 1;}

    Answer: C Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;class Test { float i,j;};class Add { public:int x,y;Add (int a=3, int b=3) { x=a; y=b; } int result() { return x+y;}};int main () { Test test; Add * padd; padd = &test;cout << padd?>result(); return 0;}

    Answer: C Next Question
  • What happens if character 3 is entered as input? #include <iostream>using namespace std;class A { public: int i;};int main () { int c;A obj; obj.i = 5; cin >> c; try{switch (c){case

    Answer: A Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;namespace myNamespace1{int x = 5; int y = 10;}namespace myNamespace2{float x = 3.14; float y = 1.5;}int main () {{using namespace myNamespace1; cout << x << " ";}{using namespace myNamespace2;cout << y;}return 0;}

    Answer: A Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;int main (int argc, const char * argv[]){int a = 30, b = 1, c = 5, i=10; i = b < a < c;cout << i; return 0;}

    Answer: D Next Question
Page: 1 / 52
Total Questions: 257