1 CPA - 21 - 02 - CPA - C++ Certified Associate Programmer Exam Questions Answers PDF Overview of CPA - 21 - 02 Preparation Material Get ready for CPA - 21 - 02 with our comprehensive preparation material. Dive into practice exams, meticulously crafted questions and answers, and insightful PDFs to enhance your understanding of key concepts. Our preparation material is designed to align with the latest updates, ensuring you're well - equipped to tackle the CPA - 21 - 02 examination Click here for download: https://www.certswarrior.com/exam/cpa - 21 - 02/ 2 Question: 1 Which code, inserted at line 5, generates the output "ABC"? #include <iostream> using namespace std; class A { public: //insert code here }; class B:public A { public: void Print(){ cout<< "B"; } }; class C:public B { public: void Print(){ cout<< "C"; } }; int main() { A ob1; B ob2; C ob3; A *obj; obj = &ob1; obj?>Print(); obj = &ob2; obj?>Print(); obj = &ob3; obj?>Print(); } A. void Print(){ cout<<"A";} B. virtual void Print(){ cout<<"A";} C. virtual void Print(string s){ cout<<s;} D. None of these Answer: B Question: 2 What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; class BaseClass { public: int *ptr; BaseClass(int i) { ptr = new int(i); } 3 ~BaseClass() { delete ptr; delete ptr;} void Print() { cout << *ptr; } }; void fun(BaseClass x); int main() { BaseClass o(10); fun(o); o.Print(); } void fun(BaseClass x) { cout << "Hello:"; } A. It prints: Hello:1 B. It prints: Hello: C. It prints: 10 D. Runtime error. Answer: D Question: 3 What will happen when you attempt to compile and run the following code? #include <iostream> using namespace std; int getValue(); int main() { const int x = getValue(); cout<<x; return 0; } int getValue() { return 5; } A. It will print 0 B. The code will not compile. C. It will print 5 D. It will print garbage value Answer: C Question: 4 What happens when you attempt to compile and run the following code? 4 #include <iostream> #include <string> using namespace std; class A { public: A() { cout << "A0 ";} A(string s) { cout << "A1";} }; class B : public A { public: B() { cout << "B0 ";} B(string s) { cout << "B1 ";} }; class C : private B { public: C() { cout << "C0 ";} C(string s) { cout << "C1 ";} }; int main () { B b1; C c1; return 0; } A. It prints: A0 B0 A0 B1 A0 C0 A0 C1 B. It prints: B0 B1 C0 C1 C. It prints: A0 B0 A0 B0 C0 D. It prints: B0 B1 Answer: C Question: 5 What is the output of the program? #include <iostream> #include <string> using namespace std; struct Person { int age; }; class First { Person *person; public: First() {person = new Person; person ?>age = 20; } void Print(){ cout << person?>age; 5 } }; int main() { First t[2]; for (int i=0; i<2; i++) t[i].Print(); } A. It prints: 10 B. It prints: 2020 C. It prints: 22 D. It prints: 00 Answer: B Question: 6 What happens when you attempt to compile and run the following code? #include <cstdlib> #include <iostream> using namespace std; inline float sum(float a,float b) { return a+b; } int main() { float a,b; a = 1.5; b = 3.4; cout<<sum(a,b); return 0; } A. It prints: 0 B. It prints: 4.9 C. It prints: 5 D. It prints: 4 Answer: B Question: 7 What is the output of the program? #include <iostream> #include <string> using namespace std; int main() 6 { string s1="Hello"; string s2="World"; s1+=s2; cout << s1; return( 0 ); } A. It prints: HelloWorld B. It prints: Hello C. It prints: World D. It prints: HelWorld Answer: A Question: 8 What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; #define DEF_A 0 #define DEF_B DEF_A+1 #define DEF_C DEF_B+1 int main(int argc, char *argv[]) { cout << DEF_C; return 0; } A. It prints: 2 B. It prints: 10 C. It prints: 0 D. It prints: 1 Answer: A Question: 9 What happens when you attempt to compile and run the following code? #include <iostream> using namespace std; void set(struct person*); struct person { int age; }; int main() { struct person e = {18}; 7 set(&e); cout<< e.age; return 0; } void set(struct person *p) { p?>age = p?>age + 1; } A. It prints: 18 B. It prints: 19 C. It prints: 20 D. It prints: 0 Answer: B Question: 10 Point out an error in the program. #include < iostream> using namespace std; int main() { const int x=1; int const *y=&x; cout<<*y; return 0; } A. No error B. Error: unknown pointer conversion C. cannot convert from 'const int *' to 'int *const' D. Compilation error Answer: A 8 Paragraph 2: Practice Exams and Questions Supercharge your preparation with our practice exams for CPA - 21 - 02. Each exam is strategically structured to simulate real t est conditions, giving you a competitive edge. The carefully curated questions cover a wide array of topics, allowing you to master the intricacies of CPA - 21 - 02 and boost your confidence before the actual exam. In - Depth PDFs for CPA - 21 - 02 T he secr ets of CPA - 21 - 0 2 with our in - depth PDFs. These documents provide comprehensive coverage of essential topics, offering a deep dive into the intricacies of the examination syllabus. Whether you're a beginner or aiming for mastery, our PDFs cater to all level s of proficiency, making your preparation journey seamless and effective. Click here for download: https://www.certswarrior.com /exam/cpa - 21 - 02/ Dumps for CPA - 21 - 02 Mastery Gain an extra edge with our specially curated dumps for CPA - 21 - 02. These resources are designed to reinforce your knowledge and provide a real - world per spective on exam scenarios. Our dumps are meticulously prepared, ensuring that you're well - prepared for any challenge that may arise during the CPA - 21 - 02 examination. 9