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
    Answer: C Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>#include <string>using namespace std; class Second;class Base {int age; public:Base () { age=5; };friend void set(Base &ob, Second &so); void Print() { cout << age;}};class Second {string name; public:friend void set(Base &ob, Second &so); void Print() { cout << name;}};void set(Base &ob, Second &so) { ob.age = 0; so.name = "Bill";}int main () {Base a; Second b; set(a,b);

    Answer: A Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>#include <string>using namespace std;class A {int x; protected:int y; public:int z;A() { x=1; y=2; z=3; }};class B : public A { string z;public:void set() {y = 4;z = "John";}void Print() { cout << y << z;}};int main () { B b; b.set();b.Print(); return 0;}

    Answer: A Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;int op(int x, int y){return x?y;}int op(int x, float y){return x+y;}int main(){int i=1, j=2, k, l; float f=0.23;k = op(i, j);l = op(j, f);cout<< k << "," << l; return 0;}

    Answer: C Next Question
  • What will happen when you attempt to compile and run the following code? #include <iostream>using namespace std;int main(){const char *s;char str[] = "Hello "; s = str;while(*s) {cout << *++s;*s++;}return 0;}

    Answer: A Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;int op(int x, int y); float op(int x, float y);int main(){int i=1, j=2, k; float f=0.3;k = op(i, j);cout<< k << "," << op(0, f); return 0;}int op(int x, int y){return x+y;}float op(int x, float y){return x?y;}

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

    Answer: C Next Question
  • Which code, inserted at line 8, generates the output "0102020"? #include <iostream>using namespace std;class Base { static int age; public:Base () {};~Base () {};//insert code herevoid Print() { cout << age;}};int Base::age=0;int main () { Base a,*b;b = new Base(); a.Print();a.setAge(10);

    Answer: D Next Question
  • What is not inherited from the base class?

    Answer: A, ,B, ,C Next Question
  • What happens when you attempt to compile and run the following code? #include <iostream>using namespace std;int op(int x, int y){int i;i = x + y; return i;}int main(){int i=1, j=2, k, l;k = op(i, j);l = op(j, i);cout<< k << "," << l; return 0;}

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